{"record":{"id":"16c51a86a3ef3ac7","repo":"RVC-Boss/GPT-SoVITS","slug":"files-not-found-paths","errorCode":null,"errorMessage":"Files not found: {paths}","messagePattern":"Files not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"GPT_SoVITS/text/g2pw/onnx_api.py","lineNumber":71,"sourceCode":"    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:\n            r.raise_for_status()\n            with open(zip_dir, \"wb\") as f:\n                for chunk in r.iter_content(chunk_size=8192):\n                    if chunk:\n                        f.write(chunk)\n\n        print(\"Extracting g2pw model...\")","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/GPT_SoVITS/text/g2pw/onnx_api.py#L53-L89","documentation":"FileNotFoundError from _find_first_existing_file(): g2pw initialization probes several absolute/relative candidate paths for a required model file (the .onnx / tokenizer assets) and returns the first that exists; if none exist it raises with the whole candidate list. It is the multi-path variant of [13] and almost always means the G2PWModel assets were never downloaded to any searched location.","triggerScenarios":"G2POnnxConverter init resolving the onnx model path: every probed path (default GPT_SoVITS/text/g2pw/G2PWModel/... variants) fails os.path.exists().","commonSituations":"Fresh install where download step was skipped; Chinese TTS frontend enabled (zh language triggers g2pw) without the model bundle; model directory renamed; running from a different cwd so relative candidates miss.","solutions":["Run the provided downloader (download_and_decompress('G2PWModel/')) or manually fetch G2PWModel_1.1.zip and extract so at least one probed path exists.","Run from the repository root or pass absolute model_dir so relative candidate paths resolve.","Check each path in the error message and create/ symlink the model at one of them.","If g2pw is optional for you, ensure the frontend falls back to pypinyin instead of hard-requiring g2pw."],"exampleFix":"# before\n# FileNotFoundError: Files not found: ('G2PWModel/chinese-ert-base.onnx', ...)\nconverter = G2POnnxConverter()\n\n# after\nfrom GPT_SoVITS.text.g2pw.onnx_api import download_and_decompress\ndownload_and_decompress(\"GPT_SoVITS/text/g2pw/G2PWModel/\")\nconverter = G2POnnxConverter(model_dir=\"GPT_SoVITS/text/g2pw/G2PWModel/\")","handlingStrategy":"validation","validationCode":"import os\nif not any(p and os.path.exists(p) for p in candidate_paths):\n    from GPT_SoVITS.text.g2pw.onnx_api import download_and_decompress\n    download_and_decompress(\"GPT_SoVITS/text/g2pw/G2PWModel/\")","typeGuard":null,"tryCatchPattern":"try:\n    model_path = _find_first_existing_file(*paths)\nexcept FileNotFoundError:\n    download_and_decompress(\"GPT_SoVITS/text/g2pw/G2PWModel/\")\n    model_path = _find_first_existing_file(*paths)","preventionTips":["Run g2pw model download as a provisioning step, not at first request.","Use absolute model_dir and run from repo root so all candidate paths resolve.","Cache the resolved path after first success to skip probing."],"tags":["g2pw","model-weights","missing-file","onnx","chinese-frontend"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}