{"record":{"id":"731eabc21cd9ad9f","repo":"RVC-Boss/GPT-SoVITS","slug":"cannot-locate-filename-in-candidate-dirs-candi","errorCode":null,"errorMessage":"Cannot locate {filename} in candidate dirs: {candidate_dirs}","messagePattern":"Cannot locate (.+?) in candidate dirs: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"GPT_SoVITS/text/g2pw/onnx_api.py","lineNumber":64,"sourceCode":"    preds = np.argmax(probs, axis=1).tolist()\n    max_probs = []\n    for index, arr in zip(preds, probs.tolist()):\n        max_probs.append(arr[index])\n    all_preds += [labels[pred] for pred in preds]\n    all_confidences += max_probs\n\n    return all_preds, all_confidences\n\n\ndef _load_json_from_candidates(filename: str, candidate_dirs: List[str]) -> Dict[str, Any]:\n    for candidate_dir in candidate_dirs:\n        if not candidate_dir:\n            continue\n        json_path = os.path.join(candidate_dir, filename)\n        if os.path.exists(json_path):\n            with open(json_path, \"r\", encoding=\"utf-8\") as fr:\n                return json.load(fr)\n    raise FileNotFoundError(f\"Cannot locate {filename} in candidate dirs: {candidate_dirs}\")\n\n\ndef _find_first_existing_file(*paths: str) -> str:\n    for path in paths:\n        if path and os.path.exists(path):\n            return path\n    raise FileNotFoundError(f\"Files not found: {paths}\")\n\n\ndef download_and_decompress(model_dir: str = \"G2PWModel/\"):\n    if not os.path.exists(model_dir):\n        parent_directory = os.path.dirname(model_dir)\n        zip_dir = os.path.join(parent_directory, \"G2PWModel_1.1.zip\")\n        extract_dir = os.path.join(parent_directory, \"G2PWModel_1.1\")\n        extract_dir_new = os.path.join(parent_directory, \"G2PWModel\")\n        print(\"Downloading g2pw model...\")\n        modelscope_url = \"https://www.modelscope.cn/models/kamiorinn/g2pw/resolve/master/G2PWModel_1.1.zip\"\n        with requests.get(modelscope_url, stream=True) as r:","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/GPT_SoVITS/text/g2pw/onnx_api.py#L46-L82","documentation":"FileNotFoundError from _load_json_from_candidates(): the g2pw (grapheme-to-pinyin with BERT) ONNX annotator looks for its metadata/config JSONs (e.g. polygraph / id maps) across a list of candidate directories and none of them contains the file. This is an incomplete-model-installation error: the G2PWModel directory exists only partially or the file names expected by this code version are absent.","triggerScenarios":"Loading the g2pw ONNX model (G2POnnxConverter init → _load_json_from_candidates) when G2PWModel/ is missing, half-extracted, or from an older version lacking the JSON being requested; also when candidate dir strings are all empty/None.","commonSituations":"Zip extraction interrupted so only the .onnx landed; user downloaded an older G2PWModel_1.1 bundle while the code expects extra files; Docker image trimmed data files; project deployed with G2PWModel elsewhere and candidate dirs not including that location.","solutions":["Re-download/re-extract the full G2PWModel bundle (download_and_decompress() or the manual zip) so all JSONs sit next to the .onnx.","Compare the file list printed in the error against your G2PWModel directory and fetch the missing JSON specifically.","If the model lives in a non-default location, add that directory to the candidate dirs passed into the loader (env/arg supported by the caller).","Verify no empty-string candidate dirs silently skip your intended path."],"exampleFix":"# before\nconverter = G2POnnxConverter(model_dir=\"G2PWModel/\")  # FileNotFoundError: Cannot locate ... in candidate dirs\n\n# after: ensure complete model dir, or extend candidates\n# ls G2PWModel/  -> bert-base.onnx  polygraphunicode.txt  id2pinyin.json ... all present\nconverter = G2POnnxConverter(model_dir=\"G2PWModel/\")","handlingStrategy":"validation","validationCode":"import os\nrequired = [\"polygraphunicode.txt\", \"id2pinyin.json\"]  # per error message\nmissing = [f for f in required if not any(os.path.exists(os.path.join(d, f)) for d in candidate_dirs)]\nif missing:\n    raise SystemExit(f\"G2PWModel incomplete, missing {missing} — re-download bundle\")","typeGuard":null,"tryCatchPattern":"try:\n    data = _load_json_from_candidates(filename, candidate_dirs)\nexcept FileNotFoundError:\n    download_and_decompress(\"GPT_SoVITS/text/g2pw/G2PWModel/\")\n    data = _load_json_from_candidates(filename, candidate_dirs + [\"GPT_SoVITS/text/g2pw/G2PWModel\"])","preventionTips":["Install the complete G2PWModel bundle; verify the file list after extraction.","Append your model directory to candidate dirs when storing models outside the repo.","Avoid empty-string candidate dirs which silently skip."],"tags":["g2pw","model-weights","missing-file","chinese-frontend","onnx"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}