{"record":{"id":"0baafcdfad437d6e","repo":"BerriAI/litellm","slug":"could-not-decode-audio-for-riva-stt-install-audio","errorCode":null,"errorMessage":"Could not decode audio for Riva STT. Install audio extras (`pip install 'litellm[stt-nvidia-riva]'`) or convert your audio to wav/flac/ogg before calling the API. Underlying error: {sf_error}","messagePattern":"Could not decode audio for Riva STT\\. Install audio extras \\(`pip install 'litellm\\[stt-nvidia-riva\\]'`\\) or convert your audio to wav/flac/ogg before calling the API\\. Underlying error: (.+?)","errorType":"http","errorClass":"NvidiaRivaException","httpStatus":400,"severity":"error","filePath":"litellm/llms/nvidia_riva/audio_transcription/audio_utils.py","lineNumber":115,"sourceCode":"\n    sf_error: Exception | None = None\n    try:\n        import soundfile as sf\n\n        with io.BytesIO(file_bytes) as buf:\n            data, source_rate = sf.read(buf, dtype=\"float32\", always_2d=False)\n        return cast(\"FloatArray\", data), int(source_rate)\n    except ImportError as e:\n        sf_error = e\n    except Exception as e:\n        # soundfile raises RuntimeError / LibsndfileError for formats it\n        # cannot decode (mp3 on older libsndfile, m4a, webm, ...).\n        sf_error = e\n\n    try:\n        import audioread\n    except ImportError as e:\n        raise NvidiaRivaException(\n            status_code=400,\n            message=(\n                \"Could not decode audio for Riva STT. Install audio extras \"\n                f\"(`pip install 'litellm[stt-nvidia-riva]'`) or convert your \"\n                f\"audio to wav/flac/ogg before calling the API. \"\n                f\"Underlying error: {sf_error}\"\n            ),\n        ) from e\n\n    # audioread backends (FFmpeg subprocess, GStreamer, Core Audio) require a\n    # filesystem path, so spill the bytes to a temp file. mkstemp is portable\n    # to Windows where re-opening a NamedTemporaryFile is not allowed.\n    fd, tmp_path = tempfile.mkstemp(suffix=\".audio\")\n    try:\n        with os.fdopen(fd, \"wb\") as tmp_file:\n            tmp_file.write(file_bytes)\n        try:\n            with audioread.audio_open(tmp_path) as src:","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/nvidia_riva/audio_transcription/audio_utils.py#L97-L133","documentation":"Raised by litellm's Riva audio decoder when soundfile cannot decode the audio (unsupported format or soundfile missing) AND the audioread fallback is not installed. The message embeds the underlying soundfile error and instructs installing the stt-nvidia-riva extra or pre-converting to wav/flac/ogg.","triggerScenarios":"Calling litellm.transcription() with nvidia_riva/* on an environment lacking the stt extras, feeding formats soundfile can't handle (m4a, webm, mp3 on older libsndfile) so decode falls through to the missing audioread fallback.","commonSituations":"Recording browser audio (webm/opus) or phone audio (m4a/amr) and sending it straight to Riva STT on a minimal install; CI environments without ffmpeg/libsndfile system libs.","solutions":["pip install 'litellm[stt-nvidia-riva]' (adds soundfile/audioread) and install system libsndfile/ffmpeg.","Pre-convert audio to wav or flac with ffmpeg before calling transcription.","If soundfile is installed but failing, update libsndfile (newer versions decode mp3).","Check the embedded 'Underlying error' to see which decode path failed."],"exampleFix":"# before\nwith open(\"voice-memo.m4a\", \"rb\") as f:\n    litellm.transcription(model=\"nvidia_riva/riva_asr\", file=f)\n\n# after: convert to wav first\nimport subprocess\nsubprocess.run([\"ffmpeg\", \"-i\", \"voice-memo.m4a\", \"-ar\", \"16000\", \"-ac\", \"1\", \"memo.wav\"], check=True)\nwith open(\"memo.wav\", \"rb\") as f:\n    litellm.transcription(model=\"nvidia_riva/riva_asr\", file=f)","handlingStrategy":"fallback","validationCode":"def can_decode_locally(path: str) -> bool:\n    try:\n        import soundfile as sf  # noqa: F401\n        return True\n    except ImportError:\n        pass\n    import shutil\n    return shutil.which(\"ffmpeg\") is not None","typeGuard":null,"tryCatchPattern":"from litellm.exceptions import APIError\ntry:\n    litellm.transcription(model=\"nvidia_riva/riva_asr\", file=f)\nexcept APIError as e:\n    if \"Could not decode audio\" in str(e) and \"Install audio extras\" in str(e):\n        # fallback: convert with ffmpeg then retry\n        wav = convert_to_wav(f.name)\n        litellm.transcription(model=\"nvidia_riva/riva_asr\", file=open(wav, \"rb\"))\n    else:\n        raise","preventionTips":["Normalize all user audio to wav/flac at ingest with ffmpeg.","Install 'litellm[stt-nvidia-riva]' plus system libsndfile and ffmpeg in the image.","Reject unsupported containers (m4a/webm) at upload unless a converter is present."],"tags":["nvidia-riva","audio-transcription","audio-format","dependency","soundfile"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}