{"record":{"id":"d852d029c6e74208","repo":"sgl-project/sglang","slug":"original-sr-must-be-a-positive-number-but-got-se","errorCode":null,"errorMessage":"original_sr must be a positive number, but got {self.audio[1]}","messagePattern":"original_sr must be a positive number, but got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/mimo_audio.py","lineNumber":67,"sourceCode":"        if not isinstance(self.audio, (str, bytes, tuple, torch.Tensor, np.ndarray)):\n            raise ValueError(\n                f\"audio must be a str, bytes, tuple, torch.Tensor, or np.ndarray, but got {type(self.audio)}\"\n            )\n        if isinstance(self.audio, tuple):\n            if (\n                len(self.audio) != 2\n                or not isinstance(self.audio[0], torch.Tensor)\n                or not isinstance(self.audio[1], (int, float))\n            ):\n                raise ValueError(\n                    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])}\"\n                )\n            if self.audio[0].ndim != 1:\n                raise ValueError(\n                    f\"waveform must be a 1D tensor, but got {self.audio[0].ndim}D tensor\"\n                )\n            if self.audio[1] <= 0:\n                raise ValueError(\n                    f\"original_sr must be a positive number, but got {self.audio[1]}\"\n                )\n        if isinstance(self.audio, torch.Tensor) and self.audio.ndim != 2:\n            raise ValueError(\n                f\"audio must be a 2D tensor, but got {self.audio.ndim}D tensor\"\n            )\n\n\nclass MiMoAudioPipeline:\n    \"\"\"Stateful audio preprocessing pipeline.\n\n    Composable: held by both MiMoProcessor (multimodal) and MiMoV2ASRProcessor.\n    Owns the mel spectrogram, resampler cache, http session, and the special\n    token ids for ``<|sosp|> <|empty|>* <|eosp|>`` placeholders.\n    \"\"\"\n\n    def __init__(\n        self,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/mimo_audio.py#L49-L85","documentation":"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.","triggerScenarios":"Passing sr = 0, a negative number, or a value that became 0 through a parsing/default bug in the (waveform, sr) tuple.","commonSituations":"Sample rate read from a metadata field that defaults to 0, or computed by a buggy division; passing -1 as a sentinel meaning 'unknown'.","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"],"exampleFix":"# before\nsr = int(meta.get(\"sample_rate\", 0))\naudio = (waveform, sr)\n# after\nsr = int(meta[\"sample_rate\"])  # 16000\naudio = (waveform, sr)","handlingStrategy":"validation","validationCode":"assert isinstance(audio[1], (int, float)) and audio[1] > 0, f\"bad sr {audio[1]!r}\"","typeGuard":"def is_valid_sr(sr) -> bool:\n    return isinstance(sr, (int, float)) and sr > 0","tryCatchPattern":null,"preventionTips":["Never use 0/-1 sentinels for sample rate; fail loudly instead","Parse sr from trusted metadata or torchaudio.info"],"tags":["multimodal","audio","sample-rate","mimo"],"backgroundTag":"invalid-sample-rate","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}