{"record":{"id":"2e1388190b421964","repo":"fishaudio/fish-speech","slug":"audio-file-not-found-wav-file-path","errorCode":null,"errorMessage":"Audio file not found: {wav_file_path}","messagePattern":"Audio file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"fish_speech/inference_engine/reference_loader.py","lineNumber":214,"sourceCode":"            wav_file_path: Path to the audio file to copy\n            reference_text: Text content for the .lab file\n\n        Raises:\n            FileExistsError: If the reference ID already exists\n            FileNotFoundError: If the audio file doesn't exist\n            OSError: If file operations fail\n        \"\"\"\n        self._validate_id(id)\n\n        # Check if reference already exists\n        ref_dir = Path(\"references\") / id\n        if ref_dir.exists():\n            raise FileExistsError(f\"Reference ID '{id}' already exists\")\n\n        # Check if audio file exists\n        audio_path = Path(wav_file_path)\n        if not audio_path.exists():\n            raise FileNotFoundError(f\"Audio file not found: {wav_file_path}\")\n\n        # Validate audio file extension\n        if audio_path.suffix.lower() not in AUDIO_EXTENSIONS:\n            raise ValueError(\n                f\"Unsupported audio format: {audio_path.suffix}. Supported formats: {', '.join(AUDIO_EXTENSIONS)}\"\n            )\n\n        try:\n            # Create reference directory\n            ref_dir.mkdir(parents=True, exist_ok=False)\n\n            # Determine the target audio filename with original extension\n            target_audio_path = ref_dir / f\"sample{audio_path.suffix}\"\n\n            # Copy audio file\n            import shutil\n\n            shutil.copy2(audio_path, target_audio_path)","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/fish_speech/inference_engine/reference_loader.py#L196-L232","documentation":"Before creating a reference, add_reference verifies the supplied audio file exists on disk. A missing file raises FileNotFoundError with the given path, so the error is always a path problem on the caller's side, not a library issue.","triggerScenarios":"Calling add_reference(\"id\", \"ref.wav\") when the wav path is wrong, relative to a different working directory, or the file hasn't been uploaded/saved yet.","commonSituations":"Relative paths resolved from a different CWD (server vs CLI), audio file still in a temp upload buffer not yet flushed to disk, or typo'd filenames.","solutions":["Use an absolute path: str(Path(wav).resolve())","Verify the file is fully written/flushed before calling add_reference","Check the path exists in the same process/CWD that runs ReferenceLoader"],"exampleFix":"# before\nloader.add_reference(\"my_voice\", \"ref.wav\")  # FileNotFoundError if CWD differs\n\n# after\nfrom pathlib import Path\nloader.add_reference(\"my_voice\", str(Path(\"ref.wav\").resolve()))","handlingStrategy":"validation","validationCode":"from pathlib import Path\nwav = Path(wav_file_path).resolve()\nassert wav.is_file(), f\"audio file missing: {wav}\"","typeGuard":null,"tryCatchPattern":"try:\n    loader.add_reference(ref_id, wav)\nexcept FileNotFoundError as e:\n    raise RuntimeError(f\"audio file not found — check path/CWD: {wav_file_path}\") from e","preventionTips":["Always pass absolute, resolved paths to add_reference","Confirm temp uploads are flushed to disk before registering them"],"tags":["file-not-found","path","audio","python"],"backgroundTag":"file-not-found","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}