{"record":{"id":"7dabf3f436796899","repo":"RVC-Boss/GPT-SoVITS","slug":"ref-audio-path-not-exists","errorCode":null,"errorMessage":"{ref_audio_path} not exists","messagePattern":"(.+?) not exists","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"GPT_SoVITS/TTS_infer_pack/TTS.py","lineNumber":1136,"sourceCode":"\n        if no_prompt_text and self.configs.use_vocoder:\n            raise NO_PROMPT_ERROR(\"prompt_text cannot be empty when using SoVITS_V3\")\n\n        if ref_audio_path in [None, \"\"] and (\n            (self.prompt_cache[\"prompt_semantic\"] is None) or (self.prompt_cache[\"refer_spec\"] in [None, []])\n        ):\n            raise ValueError(\n                \"ref_audio_path cannot be empty, when the reference audio is not set using set_ref_audio()\"\n            )\n\n        ###### setting reference audio and prompt text preprocessing ########\n        t0 = time.perf_counter()\n        if (ref_audio_path is not None) and (\n            ref_audio_path != self.prompt_cache[\"ref_audio_path\"]\n            or (self.is_v2pro and self.prompt_cache[\"refer_spec\"][0][1] is None)\n        ):\n            if not os.path.exists(ref_audio_path):\n                raise ValueError(f\"{ref_audio_path} not exists\")\n            self.set_ref_audio(ref_audio_path)\n\n        aux_ref_audio_paths = aux_ref_audio_paths if aux_ref_audio_paths is not None else []\n        paths = set(aux_ref_audio_paths) & set(self.prompt_cache[\"aux_ref_audio_paths\"])\n        if not (len(list(paths)) == len(aux_ref_audio_paths) == len(self.prompt_cache[\"aux_ref_audio_paths\"])):\n            self.prompt_cache[\"aux_ref_audio_paths\"] = aux_ref_audio_paths\n            self.prompt_cache[\"refer_spec\"] = [self.prompt_cache[\"refer_spec\"][0]]\n            for path in aux_ref_audio_paths:\n                if path in [None, \"\"]:\n                    continue\n                if not os.path.exists(path):\n                    print(i18n(\"音频文件不存在，跳过：\"), path)\n                    continue\n                self.prompt_cache[\"refer_spec\"].append(self._get_ref_spec(path))\n\n        if not no_prompt_text:\n            prompt_text = prompt_text.strip(\"\\n\")\n            if prompt_text[-1] not in splits:","sourceCodeStart":1118,"sourceCodeEnd":1154,"githubUrl":"https://github.com/RVC-Boss/GPT-SoVITS/blob/d523079fc05d9a8028d6085bffe4a2757c32abb6/GPT_SoVITS/TTS_infer_pack/TTS.py#L1118-L1154","documentation":"ValueError raised when the provided ref_audio_path fails os.path.exists() at the moment the handler decides to (re)prime the reference audio. This is a plain wrong-path error: the path was supplied, is different from the cached one, but does not resolve to a file on disk.","triggerScenarios":"Calling infer_batch/run/set_ref_audio with a path that doesn't exist — typo, relative path resolved against the wrong working directory, URL instead of local file, or a file deleted/renamed after the UI listing was built.","commonSituations":"Path contains a trailing quote/space from copy-paste (partly handled by clean_path elsewhere but not here); webui launched from a different cwd so relative paths break; file on a network mount that disconnected; user pastes an http:// URL where a local file is required.","solutions":["Check the path: print/copy the exact ref_audio_path from the error and confirm the file exists (ls / dir).","Use an absolute path to avoid working-directory ambiguity.","If the source is a URL, download it to a local file first, then pass the local path.","Sanitize user input (strip quotes/newlines/spaces) before passing, e.g. with tools.my_utils.clean_path."],"exampleFix":"# before\nhandler.set_ref_audio(\"'ref.wav\\n\")  # ValueError: ... not exists\n\n# after\nimport os\nfrom tools.my_utils import clean_path\nref = os.path.abspath(clean_path(user_input))\nif not os.path.exists(ref):\n    raise SystemExit(f\"download/provide {ref} first\")\nhandler.set_ref_audio(ref)","handlingStrategy":"validation","validationCode":"import os\nref = os.path.abspath(ref_audio_path) if ref_audio_path else None\nif ref is None or not os.path.exists(ref):\n    raise ValueError(f\"reference audio not found: {ref_audio_path!r}\")","typeGuard":"def is_valid_audio_path(p: str | None) -> bool:\n    return bool(p) and os.path.exists(os.path.abspath(str(p).strip().strip('\"\\'')))","tryCatchPattern":null,"preventionTips":["Always pass absolute paths for reference audio.","Clean copy-pasted paths (strip quotes/spaces/newlines) before use.","Download remote URLs to local files before inference."],"tags":["file-path","reference-audio","validation","tts"],"backgroundTag":null,"analyzedSha":"d523079fc05d9a8028d6085bffe4a2757c32abb6","analyzedAt":"2026-08-15T01:06:46.402Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}