{"record":{"id":"f81bf0f9095f52ac","repo":"RVC-Boss/GPT-SoVITS","slug":"you-input-a-wrong-audio-path-that-does-not-exists","errorCode":null,"errorMessage":"You input a wrong audio path that does not exists, please fix it!","messagePattern":"You input a wrong audio path that does not exists, please fix it!","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/my_utils.py","lineNumber":23,"sourceCode":"\r\nimport ffmpeg\r\nimport gradio as gr\r\nimport numpy as np\r\nimport pandas as pd\r\n\r\nfrom tools.i18n.i18n import I18nAuto\r\n\r\ni18n = I18nAuto(language=os.environ.get(\"language\", \"Auto\"))\r\n\r\n\r\ndef load_audio(file, sr):\r\n    try:\r\n        # https://github.com/openai/whisper/blob/main/whisper/audio.py#L26\r\n        # This launches a subprocess to decode audio while down-mixing and resampling as necessary.\r\n        # Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.\r\n        file = clean_path(file)  # 防止小白拷路径头尾带了空格和\"和回车\r\n        if os.path.exists(file) is False:\r\n            raise RuntimeError(\"You input a wrong audio path that does not exists, please fix it!\")\r\n        out, _ = (\r\n            ffmpeg.input(file, threads=0)\r\n            .output(\"-\", format=\"f32le\", acodec=\"pcm_f32le\", ac=1, ar=sr)\r\n            .run(cmd=[\"ffmpeg\", \"-nostdin\"], capture_stdout=True, capture_stderr=True)\r\n        )\r\n    except Exception:\r\n        out, _ = (\r\n            ffmpeg.input(file, threads=0)\r\n            .output(\"-\", format=\"f32le\", acodec=\"pcm_f32le\", ac=1, ar=sr)\r\n            .run(cmd=[\"ffmpeg\", \"-nostdin\"], capture_stdout=True)\r\n        )  # Expose the Error\r\n        raise RuntimeError(i18n(\"音频加载失败\"))\r\n\r\n    return np.frombuffer(out, np.float32).flatten()\r\n\r\n\r\ndef clean_path(path_str: str):\r\n    if path_str.endswith((\"\\\\\", \"/\")):\r","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/tools/my_utils.py#L5-L41","documentation":"RuntimeError from load_audio(): after clean_path() strips stray quotes/spaces/newlines, the function checks os.path.exists(file) and rejects the call with an English message when the path still doesn't resolve. It is the first, specific stage of audio loading — the file simply isn't there (typo, wrong cwd, not yet downloaded).","triggerScenarios":"Calling tools.my_utils.load_audio(file, sr) (used throughout training-data preparation and preprocessing) with a non-existent path — including paths that look fine but contain invisible characters or a wrong relative base.","commonSituations":"Training list .list files referencing moved/renamed wav files; relative paths resolved from a different cwd; trailing quote/space from copying a path out of a chat/browser (clean_path fixes common ones but not e.g. full-width or mid-string garbage); empty path from a bad CSV field.","solutions":["Verify the exact path exists (paste it into ls); fix typos and use absolute paths.","Regenerate the training file list after moving audio; or batch-validate all entries with os.path.exists before starting a long preprocessing job.","Run the process from the directory the relative paths are relative to, or normalize with os.path.abspath.","Download/restore the missing file if it comes from a remote dataset."],"exampleFix":"# before\naudio = load_audio(\"dataset/utt_0001.wav\", 32000)  # RuntimeError: wrong audio path...\n\n# after\nimport os\np = \"dataset/utt_0001.wav\"\nassert os.path.exists(p), f\"missing audio: {p} — fix list file or restore file\"\naudio = load_audio(p, 32000)","handlingStrategy":"validation","validationCode":"import os\nfrom tools.my_utils import clean_path\npath = clean_path(user_path)\nif not os.path.exists(os.path.abspath(path)):\n    raise ValueError(f\"audio file not found: {path!r}\")\naudio = load_audio(path, sr)","typeGuard":"def is_loadable_audio(path: str | None) -> bool:\n    return bool(path) and os.path.exists(clean_path(path))","tryCatchPattern":null,"preventionTips":["Batch-validate all paths in training .list files before long preprocessing runs.","Prefer absolute paths; run jobs from the directory the list file assumes.","Apply clean_path to any user- or chat-supplied path."],"tags":["audio-io","file-path","training-data","validation"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}