{"record":{"id":"f81e327b3ead45a9","repo":"OpenBMB/VoxCPM","slug":"retry-on-bad-cases-is-not-supported-in-streaming-m-f81e32","errorCode":null,"errorMessage":"Retry on bad cases is not supported in streaming mode, setting retry_badcase=False.","messagePattern":"Retry on bad cases is not supported in streaming mode, setting retry_badcase=False\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/voxcpm/model/voxcpm2.py","lineNumber":487,"sourceCode":"        self,\n        target_text: str,\n        prompt_text: str = \"\",\n        prompt_wav_path: str = \"\",\n        reference_wav_path: str = \"\",\n        min_len: int = 2,\n        max_len: int = 2000,\n        inference_timesteps: int = 10,\n        cfg_value: float = 2.0,\n        retry_badcase: bool = False,\n        retry_badcase_max_times: int = 3,\n        retry_badcase_ratio_threshold: float = 6.0,\n        trim_silence_vad: bool = False,\n        streaming: bool = False,\n        streaming_prefix_len: int = 4,\n        seed: Optional[int] = None,\n    ) -> Generator[torch.Tensor, None, None]:\n        if retry_badcase and streaming:\n            warnings.warn(\"Retry on bad cases is not supported in streaming mode, setting retry_badcase=False.\")\n            retry_badcase = False\n\n        if reference_wav_path and prompt_wav_path:\n            # Combined mode: reference isolation prefix + continuation suffix\n            text = prompt_text + target_text\n            text_token = torch.LongTensor(self.text_tokenizer(text))\n            text_token = torch.cat(\n                [\n                    text_token,\n                    torch.tensor([self.audio_start_token], dtype=torch.int32, device=text_token.device),\n                ],\n                dim=-1,\n            )\n            text_length = text_token.shape[0]\n\n            ref_feat = self._encode_wav(\n                reference_wav_path,\n                padding_mode=\"right\",","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/OpenBMB/VoxCPM/blob/f5a1c6a6b901bc732e20f0d59a369f6829ad717a/src/voxcpm/model/voxcpm2.py#L469-L505","documentation":"voxcpm2's core generation routine _generate warns when retry_badcase and streaming are both enabled. Streaming mode emits audio incrementally via a generator, so a failed/bad generation step cannot be re-sampled without breaking the stream; the library downgrades retry_badcase to False and continues without retries.","triggerScenarios":"Calling generate_streaming(...) or _generate(...) on the voxcpm2 model with retry_badcase=True and streaming=True (both are parameters on the same method; check occurs before any tokenization/generation work).","commonSituations":"Porting a batch/serving script tuned for non-streaming generation (where retry_badcase improves robustness on hard prompts) to a real-time streaming endpoint; a shared config dict applied to both streaming and non-streaming code paths; a newer voxcpm2 wrapper exposing retry_badcase by default.","solutions":["Set retry_badcase=False in streaming calls — the warning is purely informational and the library already does this.","If you rely on retry to avoid artifacts on difficult text, switch to the non-streaming generate(...) API.","Optionally suppress: warnings.filterwarnings('ignore', message='Retry on bad cases is not supported in streaming mode')."],"exampleFix":"# before\nfor wav_chunk in model.generate_streaming(text, retry_badcase=True, streaming=True):\n    stream.send(wav_chunk)\n\n# after\nfor wav_chunk in model.generate_streaming(text, retry_badcase=False, streaming=True):\n    stream.send(wav_chunk)","handlingStrategy":"validation","validationCode":"def sanitize_generate_kwargs(kwargs: dict, streaming: bool) -> dict:\n    if streaming:\n        kwargs = {**kwargs, \"retry_badcase\": False}\n    return kwargs\n\nkwargs = sanitize_generate_kwargs(request.model_dump(), streaming=True)\ngen = model.generate_streaming(text, **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize generation kwargs in a single wrapper instead of passing user payloads straight to the model.","Track which options are streaming-only vs batch-only in a compatibility table for your config schema."],"tags":["voxcpm","voxcpm2","tts","streaming","retry","configuration","user-warning"],"backgroundTag":"incompatible-option-combination","analyzedSha":"f5a1c6a6b901bc732e20f0d59a369f6829ad717a","analyzedAt":"2026-08-27T05:54:30.617Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}