BerriAI/litellm · error · NvidiaRivaException
Could not decode audio for Riva STT. Convert your audio to w
Error message
Could not decode audio for Riva STT. Convert your audio to wav/flac/ogg before calling the API. Underlying error: {e} What it means
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.
Source
Thrown at litellm/llms/nvidia_riva/audio_transcription/audio_utils.py:151
with audioread.audio_open(tmp_path) as src:
source_rate = int(src.samplerate)
channels: Final = int(src.channels)
chunks: Final = []
for buf in src:
chunks.append(np.frombuffer(buf, dtype=np.int16))
if not chunks:
raise NvidiaRivaException(
status_code=400,
message="Audio decode produced no samples.",
)
interleaved = np.concatenate(chunks).astype(np.float32) / 32768.0
if channels > 1:
interleaved = interleaved.reshape(-1, channels)
return cast("FloatArray", interleaved), source_rate
except NvidiaRivaException:
raise
except Exception as e:
raise NvidiaRivaException(
status_code=400,
message=(
"Could not decode audio for Riva STT. Convert your audio to "
f"wav/flac/ogg before calling the API. Underlying error: {e}"
),
) from e
finally:
try:
os.unlink(tmp_path)
except OSError:
pass
def _resample(samples: "FloatArray", source_rate: int, target_rate: int) -> "FloatArray":
"""
Resample mono float32 ``samples`` from ``source_rate`` to ``target_rate``.
Prefers high-quality polyphase resampling when ``soxr`` or ``scipy`` isView on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before
litellm.transcription(model="nvidia_riva/riva_asr", file=open("clip.amr", "rb"))
# after: normalize format at ingest time
subprocess.run(["ffmpeg", "-i", "clip.amr", "-ar", "16000", "-ac", "1", "clip.wav"], check=True)
litellm.transcription(model="nvidia_riva/riva_asr", file=open("clip.wav", "rb")) Defensive patterns
Strategy: fallback
Validate before calling
import shutil
if shutil.which("ffmpeg") is None:
raise RuntimeError("ffmpeg not installed; Riva STT cannot decode non-wav audio") Try / catch
from litellm.exceptions import APIError
try:
litellm.transcription(model="nvidia_riva/riva_asr", file=f)
except APIError as e:
if "Could not decode audio" in str(e):
wav_path = to_wav_16k_mono(f.name) # subprocess ffmpeg fallback
if wav_path:
return litellm.transcription(model="nvidia_riva/riva_asr", file=open(wav_path, "rb"))
raise
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not decode audio for Riva STT. Install audio extras (`
- numpy is required for Riva audio resampling. Install Riva ST
- Audio decode produced no samples.
- raw_response.text
- NVIDIA Riva requires `api_base` (host:port for the gRPC endp
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/9c91c3d83c7aa40a.
Report an issue: GitHub.