{"record":{"id":"26e085f6f186ed86","repo":"sgl-project/sglang","slug":"reference-audio-is-empty-audio-path","errorCode":null,"errorMessage":"reference audio is empty: {audio_path}","messagePattern":"reference audio is empty: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py","lineNumber":320,"sourceCode":"    start_time_seconds: float = 0.0,\n    source_sample_rate: int | None = None,\n) -> dict[str, Any]:\n    \"\"\"Encode a reference audio file into normalized channel-major rows.\n\n    Returns {\"rows\": [2*T, 32] fp32 cpu, \"ref_audio_t\": T,\n    \"duration_seconds\": float}.\n    \"\"\"\n    model = audio_vae\n    device = next(model.parameters()).device\n    waveform, source_rate = _load_waveform(\n        audio_path,\n        material_chain=material_chain,\n        max_duration_seconds=max_duration_seconds,\n        start_time_seconds=start_time_seconds,\n        source_sample_rate=source_sample_rate,\n    )\n    if waveform.numel() == 0:\n        raise ValueError(f\"reference audio is empty: {audio_path}\")\n    if int(source_rate) != MINIMAX_H3_AUDIO_SAMPLE_RATE:\n        waveform = _audio_resampler(int(source_rate))(waveform)\n    waveform = waveform.to(device)\n\n    with (\n        _AudioVAEDeterminismContext(),\n        set_forward_context(current_timestep=0, attn_metadata=None),\n    ):\n        audio_data = model.preprocess(\n            waveform.unsqueeze(1), MINIMAX_H3_AUDIO_SAMPLE_RATE\n        )\n        z = model.encoder(audio_data)\n        if bool(getattr(model, \"attn_proj\", False)):\n            z = model.pre_block(z.transpose(1, 2)).transpose(1, 2)\n        if not hasattr(model, \"mean_proj\"):\n            raise AttributeError(\n                \"audio VAE model must expose mean_proj for deterministic mean encoding\"\n            )","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py#L302-L338","documentation":"After decoding, the reference audio waveform has zero samples — the file/segment produced no audio at all. The check runs in minimax_h3_encode_reference_audio_rows after _load_waveform returns, before resampling and VAE encoding.","triggerScenarios":"An audio path pointing to an empty/silent-less file, a start_time beyond the media duration (ffmpeg seeks past the end and outputs nothing), or a video with no audio stream being treated as audio material.","commonSituations":"Corrupt zero-byte uploads, wrong path, trimming with an out-of-range start time, or silent videos passed through the audio chain.","solutions":["Verify the file has an audio stream and nonzero duration with ffprobe before submission","Clamp start_time_seconds to the media duration","Pre-check waveform length after a test decode and reject with a user-facing 'empty audio' message"],"exampleFix":"// before\nstart = 9999.0  # beyond clip end -> empty waveform\n\n// after\nstart = min(start, probe_duration(path) - 0.1)","handlingStrategy":"validation","validationCode":"import subprocess, json\n\ndef audio_has_samples(path) -> bool:\n    out = subprocess.run([\"ffprobe\",\"-v\",\"error\",\"-select_streams\",\"a\",\"-show_entries\",\"stream=duration\",\"-of\",\"json\",path], capture_output=True)\n    return b'\"duration\"' in out.stdout","typeGuard":null,"tryCatchPattern":"try:\n    minimax_h3_encode_reference_audio_rows(rows, ...)\nexcept ValueError as e:\n    if 'empty' in str(e):\n        return bad_request(\"audio file contains no samples\")\n    raise","preventionTips":["ffprobe for an audio stream before accepting uploads","Clamp start_time to below the media duration"],"tags":["minimax-h3","audio","empty-media"],"backgroundTag":"empty-audio-stream","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}