BerriAI/litellm · error · NvidiaRivaException
Audio decode produced no samples.
Error message
Audio decode produced no samples.
What it means
Raised by litellm's Riva audio decoder when the audioread fallback opens the audio file successfully but yields zero sample chunks — the file decodes to nothing. This indicates corrupt/near-empty audio content rather than a format or dependency problem.
Source
Thrown at litellm/llms/nvidia_riva/audio_transcription/audio_utils.py:140
),
) from e
# audioread backends (FFmpeg subprocess, GStreamer, Core Audio) require a
# filesystem path, so spill the bytes to a temp file. mkstemp is portable
# to Windows where re-opening a NamedTemporaryFile is not allowed.
fd, tmp_path = tempfile.mkstemp(suffix=".audio")
try:
with os.fdopen(fd, "wb") as tmp_file:
tmp_file.write(file_bytes)
try:
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:View on GitHub (pinned to 6c2dcb801b)
Solutions
- Check the file size and play the file locally to confirm it actually contains audio.
- Guard before calling: skip files smaller than a few hundred bytes or with zero duration.
- Re-export/re-record the source; if truncated by transfer, re-upload.
- Verify your upload pipeline wrote the complete stream (check Content-Length vs bytes written).
Example fix
# before
with open(path, "rb") as f:
litellm.transcription(model="nvidia_riva/riva_asr", file=f)
# after
if os.path.getsize(path) < 1000:
raise ValueError(f"audio file too small to contain samples: {path}")
with open(path, "rb") as f:
litellm.transcription(model="nvidia_riva/riva_asr", file=f) Defensive patterns
Strategy: validation
Validate before calling
import os
MIN_AUDIO_BYTES = 1000 # any real clip has headers + samples
if os.path.getsize(path) < MIN_AUDIO_BYTES:
raise ValueError("audio file too small to contain samples") Type guard
def is_plausible_audio(data: bytes) -> bool:
return len(data) >= 1000 and data[:4] == b"RIFF" or data[:4] == b"fLaC" or b"OggS" == data[:4] Try / catch
from litellm.exceptions import APIError
try:
litellm.transcription(model="nvidia_riva/riva_asr", file=f)
except APIError as e:
if "no samples" in str(e):
return TranscriptResult(text="") # treat silent/empty audio as empty transcript
raise Prevention
- Check file size and duration before uploading.
- Validate uploads completed fully (compare Content-Length with bytes stored).
- In recording apps, discard sessions shorter than a threshold.
When it happens
Trigger: Calling litellm.transcription() with nvidia_riva/* on a zero-byte or truncated audio file, an empty recording buffer, or a container with headers but no audio packets (interrupted recording, failed upload).
Common situations: Uploading a file that failed mid-transfer, mic permission granted but recording never started, test fixtures with empty bytes, or writing a temp file that was truncated by disk-full.
Related errors
- numpy is required for Riva audio resampling. Install Riva ST
- Could not decode audio for Riva STT. Install audio extras (`
- Could not decode audio for Riva STT. Convert your audio to w
- 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/4798931748993b91.
Report an issue: GitHub.