sgl-project/sglang · error · ValueError
original_sr must be a positive number, but got {self.audio[1
Error message
original_sr must be a positive number, but got {self.audio[1]} What it means
The sample-rate element of the (waveform, sr) tuple must be a positive int/float. Zero or negative values are rejected because resampling would be meaningless.
Source
Thrown at python/sglang/srt/multimodal/processors/mimo_audio.py:67
if not isinstance(self.audio, (str, bytes, tuple, torch.Tensor, np.ndarray)):
raise ValueError(
f"audio must be a str, bytes, tuple, torch.Tensor, or np.ndarray, but got {type(self.audio)}"
)
if isinstance(self.audio, tuple):
if (
len(self.audio) != 2
or not isinstance(self.audio[0], torch.Tensor)
or not isinstance(self.audio[1], (int, float))
):
raise ValueError(
f"audio must be a tuple of (waveform-T, original_sr-int/float), but got {len(self.audio)} elements and {type(self.audio[0])} and {type(self.audio[1])}"
)
if self.audio[0].ndim != 1:
raise ValueError(
f"waveform must be a 1D tensor, but got {self.audio[0].ndim}D tensor"
)
if self.audio[1] <= 0:
raise ValueError(
f"original_sr must be a positive number, but got {self.audio[1]}"
)
if isinstance(self.audio, torch.Tensor) and self.audio.ndim != 2:
raise ValueError(
f"audio must be a 2D tensor, but got {self.audio.ndim}D tensor"
)
class MiMoAudioPipeline:
"""Stateful audio preprocessing pipeline.
Composable: held by both MiMoProcessor (multimodal) and MiMoV2ASRProcessor.
Owns the mel spectrogram, resampler cache, http session, and the special
token ids for ``<|sosp|> <|empty|>* <|eosp|>`` placeholders.
"""
def __init__(
self,View on GitHub (pinned to 0132848349)
Solutions
- Pass the true original sample rate, e.g. 16000 or 44100
- Fix the upstream metadata read that yields 0/-1
- Validate sr > 0 before constructing the input
Example fix
# before
sr = int(meta.get("sample_rate", 0))
audio = (waveform, sr)
# after
sr = int(meta["sample_rate"]) # 16000
audio = (waveform, sr) Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(audio[1], (int, float)) and audio[1] > 0, f"bad sr {audio[1]!r}" Type guard
def is_valid_sr(sr) -> bool:
return isinstance(sr, (int, float)) and sr > 0 Prevention
- Never use 0/-1 sentinels for sample rate; fail loudly instead
- Parse sr from trusted metadata or torchaudio.info
When it happens
Trigger: Passing sr = 0, a negative number, or a value that became 0 through a parsing/default bug in the (waveform, sr) tuple.
Common situations: Sample rate read from a metadata field that defaults to 0, or computed by a buggy division; passing -1 as a sentinel meaning 'unknown'.
Related errors
- audio_sr must be positive, got {audio_sr}
- audio must be a str, bytes, tuple, torch.Tensor, or np.ndarr
- audio must be a tuple of (waveform-T, original_sr-int/float)
- waveform must be a 1D tensor, but got {self.audio[0].ndim}D
- audio must be a 2D tensor, but got {self.audio.ndim}D tensor
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/d852d029c6e74208.
Report an issue: GitHub.