{"record":{"id":"6b4a1e3acaa90faa","repo":"fishaudio/fish-speech","slug":"unsupported-audio-format-audio-path-suffix-sup","errorCode":null,"errorMessage":"Unsupported audio format: {audio_path.suffix}. Supported formats: {', '.join(AUDIO_EXTENSIONS)}","messagePattern":"Unsupported audio format: (.+?)\\. Supported formats: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fish_speech/inference_engine/reference_loader.py","lineNumber":218,"sourceCode":"            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)\n\n            # Create .lab file\n            lab_path = ref_dir / \"sample.lab\"\n            with open(lab_path, \"w\", encoding=\"utf-8\") as f:","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/fishaudio/fish-speech/blob/befe4001745417f8c42131739d862b8a6fdbd15a/fish_speech/inference_engine/reference_loader.py#L200-L236","documentation":"add_reference only accepts audio files whose extension is in AUDIO_EXTENSIONS (checked case-insensitively). Any other suffix raises ValueError listing the supported formats, preventing the loader from ingesting formats its decoder backend can't handle.","triggerScenarios":"Calling add_reference with e.g. \"clip.mp4\", \"audio.ogg\", or a file with no extension; or a double extension like \"a.wav.orig\" where suffix is \".orig\".","commonSituations":"Uploading raw phone recordings (.m4a/.ogg/.opus) directly without converting, or renamed/temp files whose extension no longer reflects the content.","solutions":["Convert the file to a supported format first, e.g. `ffmpeg -i in.ogg out.wav`","Rename files so the true extension matches the content and is in AUDIO_EXTENSIONS","Check AUDIO_EXTENSIONS (imported in reference_loader.py) for the exact accepted list before ingestion"],"exampleFix":"# before\nloader.add_reference(\"my_voice\", \"voice.ogg\")  # ValueError\n\n# after\n# ffmpeg -i voice.ogg voice.wav\nloader.add_reference(\"my_voice\", \"voice.wav\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\nAUDIO_EXT = {\".wav\", \".mp3\", \".flac\", \".ogg\", \".m4a\"}  # mirror AUDIO_EXTENSIONS\nif Path(wav).suffix.lower() not in AUDIO_EXT:\n    raise ValueError(f\"convert first: ffmpeg -i {wav} out.wav\")","typeGuard":"from pathlib import Path\n\ndef is_supported_audio(path: str, supported: set[str]) -> bool:\n    return Path(path).suffix.lower() in supported","tryCatchPattern":"try:\n    loader.add_reference(ref_id, wav)\nexcept ValueError as e:\n    if \"Unsupported audio format\" in str(e):\n        wav = convert_to_wav(wav)  # e.g. via ffmpeg\n        loader.add_reference(ref_id, wav)\n    else:\n        raise","preventionTips":["Normalize all uploads to wav/flac at ingest time with ffmpeg","Import AUDIO_EXTENSIONS from the library and validate against it rather than a hardcoded list"],"tags":["validation","audio-format","file-extension","python"],"backgroundTag":"unsupported-file-format","analyzedSha":"befe4001745417f8c42131739d862b8a6fdbd15a","analyzedAt":"2026-08-27T21:31:45.703Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}