{"record":{"id":"19e28c4d1b987c93","repo":"sgl-project/sglang","slug":"audio-must-be-a-tuple-of-waveform-t-original-sr","errorCode":null,"errorMessage":"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])}","messagePattern":"audio must be a tuple of \\(waveform-T, original_sr-int/float\\), but got (.+?) elements and (.+?) and (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/mimo_audio.py","lineNumber":59,"sourceCode":"    if audio is tuple, it is (waveform, original_sr)\n    if audio is torch.Tensor, it is tokenized input ids with shape (T, n_vq+).\n    if audio is np.ndarray, it is a pre-loaded waveform (1D, already resampled).\n    \"\"\"\n\n    audio: str | bytes | tuple | torch.Tensor | np.ndarray\n\n    def __post_init__(self):\n        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.","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/mimo_audio.py#L41-L77","documentation":"When audio is given as a tuple, it must be exactly a 2-tuple of (1D waveform Tensor, int/float original sample rate). The supplied tuple has the wrong arity or element types.","triggerScenarios":"Constructing the audio input with a 3-element tuple, a tuple whose first element is a list/ndarray instead of torch.Tensor, or whose second element is a string/non-numeric sample rate.","commonSituations":"Client builds (waveform, sr, text) triples, uses numpy waveform without converting to Tensor, or passes sr as a string parsed from a header.","solutions":["Convert the waveform to a torch.Tensor and pass a numeric sample rate: (torch.Tensor, int)","Drop extra tuple elements — keep only waveform and sample_rate","Verify len(tuple) == 2 before construction"],"exampleFix":"# before\naudio = (np_waveform, \"16000\")\n# after\naudio = (torch.from_numpy(np_waveform), 16000)","handlingStrategy":"validation","validationCode":"import torch\nassert len(audio) == 2 and isinstance(audio[0], torch.Tensor) and isinstance(audio[1], (int, float))","typeGuard":"def is_valid_audio_tuple(a) -> bool:\n    import torch\n    return (isinstance(a, tuple) and len(a) == 2\n            and isinstance(a[0], torch.Tensor)\n            and isinstance(a[1], (int, float)))","tryCatchPattern":null,"preventionTips":["Standardize on (torch.Tensor waveform, int sr) tuples end to end","Convert numpy waveforms to torch.Tensor at the boundary"],"tags":["multimodal","audio","tuple-validation","mimo"],"backgroundTag":"invalid-audio-tuple-format","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}