{"record":{"id":"9c91c3d83c7aa40a","repo":"BerriAI/litellm","slug":"could-not-decode-audio-for-riva-stt-convert-your","errorCode":null,"errorMessage":"Could not decode audio for Riva STT. Convert your audio to wav/flac/ogg before calling the API. Underlying error: {e}","messagePattern":"Could not decode audio for Riva STT\\. 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":151,"sourceCode":"            with audioread.audio_open(tmp_path) as src:\n                source_rate = int(src.samplerate)\n                channels: Final = int(src.channels)\n                chunks: Final = []\n                for buf in src:\n                    chunks.append(np.frombuffer(buf, dtype=np.int16))\n                if not chunks:\n                    raise NvidiaRivaException(\n                        status_code=400,\n                        message=\"Audio decode produced no samples.\",\n                    )\n                interleaved = np.concatenate(chunks).astype(np.float32) / 32768.0\n                if channels > 1:\n                    interleaved = interleaved.reshape(-1, channels)\n                return cast(\"FloatArray\", interleaved), source_rate\n        except NvidiaRivaException:\n            raise\n        except Exception as e:\n            raise NvidiaRivaException(\n                status_code=400,\n                message=(\n                    \"Could not decode audio for Riva STT. Convert your audio to \"\n                    f\"wav/flac/ogg before calling the API. Underlying error: {e}\"\n                ),\n            ) from e\n    finally:\n        try:\n            os.unlink(tmp_path)\n        except OSError:\n            pass\n\n\ndef _resample(samples: \"FloatArray\", source_rate: int, target_rate: int) -> \"FloatArray\":\n    \"\"\"\n    Resample mono float32 ``samples`` from ``source_rate`` to ``target_rate``.\n\n    Prefers high-quality polyphase resampling when ``soxr`` or ``scipy`` is","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/nvidia_riva/audio_transcription/audio_utils.py#L133-L169","documentation":"Raised by litellm's Riva audio decoder when the audioread fallback itself throws while decoding the temp-file copy of the audio (after soundfile already failed). The underlying exception text is embedded. This is the generic 'format undecodable in this environment' terminal state for Riva STT input.","triggerScenarios":"Calling litellm.transcription() with nvidia_riva/* on audio whose format neither soundfile nor any audioread backend (ffmpeg, GStreamer, Core Audio) can decode — e.g. proprietary/proprietary-container codecs, DRM-protected files, or systems where ffmpeg is not installed so audioread has no backend.","commonSituations":"Minimal containers without ffmpeg where audioread falls back to nothing, exotic codecs (amr-nb, opus in ogg on old libs), or corrupted files that open but error mid-decode.","solutions":["Install ffmpeg (audioread's primary backend) in the environment: apt-get install ffmpeg or equivalent.","Convert the audio to wav/flac (16 kHz mono ideal) before calling transcription.","Read the embedded 'Underlying error' to identify the failing backend and codec.","Reinstall the stt-nvidia-riva extra to restore soundfile, which handles wav/flac/ogg natively."],"exampleFix":"# before\nlitellm.transcription(model=\"nvidia_riva/riva_asr\", file=open(\"clip.amr\", \"rb\"))\n\n# after: normalize format at ingest time\nsubprocess.run([\"ffmpeg\", \"-i\", \"clip.amr\", \"-ar\", \"16000\", \"-ac\", \"1\", \"clip.wav\"], check=True)\nlitellm.transcription(model=\"nvidia_riva/riva_asr\", file=open(\"clip.wav\", \"rb\"))","handlingStrategy":"fallback","validationCode":"import shutil\nif shutil.which(\"ffmpeg\") is None:\n    raise RuntimeError(\"ffmpeg not installed; Riva STT cannot decode non-wav audio\")","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):\n        wav_path = to_wav_16k_mono(f.name)  # subprocess ffmpeg fallback\n        if wav_path:\n            return litellm.transcription(model=\"nvidia_riva/riva_asr\", file=open(wav_path, \"rb\"))\n        raise\n    raise","preventionTips":["Install ffmpeg in every environment that accepts user-uploaded audio.","Convert exotic formats (amr, opus containers) to wav before calling STT.","Log the embedded underlying error to identify which decode backend failed."],"tags":["nvidia-riva","audio-transcription","audio-format","ffmpeg","decode-error"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}