OpenBMB/VoxCPM · warning

Retry on bad cases is not supported in streaming mode, setti

Error message

Retry on bad cases is not supported in streaming mode, setting retry_badcase=False.

What it means

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.

Source

Thrown at src/voxcpm/model/voxcpm2.py:487

        self,
        target_text: str,
        prompt_text: str = "",
        prompt_wav_path: str = "",
        reference_wav_path: str = "",
        min_len: int = 2,
        max_len: int = 2000,
        inference_timesteps: int = 10,
        cfg_value: float = 2.0,
        retry_badcase: bool = False,
        retry_badcase_max_times: int = 3,
        retry_badcase_ratio_threshold: float = 6.0,
        trim_silence_vad: bool = False,
        streaming: bool = False,
        streaming_prefix_len: int = 4,
        seed: Optional[int] = None,
    ) -> Generator[torch.Tensor, None, None]:
        if retry_badcase and streaming:
            warnings.warn("Retry on bad cases is not supported in streaming mode, setting retry_badcase=False.")
            retry_badcase = False

        if reference_wav_path and prompt_wav_path:
            # Combined mode: reference isolation prefix + continuation suffix
            text = prompt_text + target_text
            text_token = torch.LongTensor(self.text_tokenizer(text))
            text_token = torch.cat(
                [
                    text_token,
                    torch.tensor([self.audio_start_token], dtype=torch.int32, device=text_token.device),
                ],
                dim=-1,
            )
            text_length = text_token.shape[0]

            ref_feat = self._encode_wav(
                reference_wav_path,
                padding_mode="right",

View on GitHub (pinned to f5a1c6a6b9)

Solutions

  1. Set retry_badcase=False in streaming calls — the warning is purely informational and the library already does this.
  2. If you rely on retry to avoid artifacts on difficult text, switch to the non-streaming generate(...) API.
  3. Optionally suppress: warnings.filterwarnings('ignore', message='Retry on bad cases is not supported in streaming mode').

Example fix

# before
for wav_chunk in model.generate_streaming(text, retry_badcase=True, streaming=True):
    stream.send(wav_chunk)

# after
for wav_chunk in model.generate_streaming(text, retry_badcase=False, streaming=True):
    stream.send(wav_chunk)
Defensive patterns

Strategy: validation

Validate before calling

def sanitize_generate_kwargs(kwargs: dict, streaming: bool) -> dict:
    if streaming:
        kwargs = {**kwargs, "retry_badcase": False}
    return kwargs

kwargs = sanitize_generate_kwargs(request.model_dump(), streaming=True)
gen = model.generate_streaming(text, **kwargs)

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of OpenBMB/VoxCPM@f5a1c6a6b9 (2026-08-27). Data as JSON: /api/errors/f81e327b3ead45a9. Report an issue: GitHub.