{"record":{"id":"4798931748993b91","repo":"BerriAI/litellm","slug":"audio-decode-produced-no-samples","errorCode":null,"errorMessage":"Audio decode produced no samples.","messagePattern":"Audio decode produced no samples\\.","errorType":"http","errorClass":"NvidiaRivaException","httpStatus":400,"severity":"error","filePath":"litellm/llms/nvidia_riva/audio_transcription/audio_utils.py","lineNumber":140,"sourceCode":"            ),\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:\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:","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/nvidia_riva/audio_transcription/audio_utils.py#L122-L158","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)."],"exampleFix":"# before\nwith open(path, \"rb\") as f:\n    litellm.transcription(model=\"nvidia_riva/riva_asr\", file=f)\n\n# after\nif os.path.getsize(path) < 1000:\n    raise ValueError(f\"audio file too small to contain samples: {path}\")\nwith open(path, \"rb\") as f:\n    litellm.transcription(model=\"nvidia_riva/riva_asr\", file=f)","handlingStrategy":"validation","validationCode":"import os\nMIN_AUDIO_BYTES = 1000  # any real clip has headers + samples\nif os.path.getsize(path) < MIN_AUDIO_BYTES:\n    raise ValueError(\"audio file too small to contain samples\")","typeGuard":"def is_plausible_audio(data: bytes) -> bool:\n    return len(data) >= 1000 and data[:4] == b\"RIFF\" or data[:4] == b\"fLaC\" or b\"OggS\" == data[:4]","tryCatchPattern":"from litellm.exceptions import APIError\ntry:\n    litellm.transcription(model=\"nvidia_riva/riva_asr\", file=f)\nexcept APIError as e:\n    if \"no samples\" in str(e):\n        return TranscriptResult(text=\"\")  # treat silent/empty audio as empty transcript\n    raise","preventionTips":["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."],"tags":["nvidia-riva","audio-transcription","empty-file","corrupt-audio"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}