OpenBMB/VoxCPM · error · ValueError
target text must be a non-empty string
Error message
target text must be a non-empty string
What it means
_generate validates that the synthesis text is a non-empty, whitespace-stripped string before running inference. Empty strings, None, non-str types, or whitespace-only text all raise ValueError.
Source
Thrown at src/voxcpm/core.py:229
cfg_value: Guidance scale for the generation model.
inference_timesteps: Number of inference steps.
min_len: Minimum audio length.
max_len: Maximum token length during generation.
normalize: Whether to run text normalization before generation.
denoise: Whether to denoise the prompt/reference audio if a
denoiser is available.
retry_badcase: Whether to retry badcase.
retry_badcase_max_times: Maximum number of times to retry badcase.
retry_badcase_ratio_threshold: Threshold for audio-to-text ratio.
streaming: Whether to return a generator of audio chunks.
seed: Optional random seed for reproducibility.
Returns:
Generator of numpy.ndarray: 1D waveform array (float32) on CPU.
Yields audio chunks for each generation step if ``streaming=True``,
otherwise yields a single array containing the final audio.
"""
if not isinstance(text, str) or not text.strip():
raise ValueError("target text must be a non-empty string")
if prompt_wav_path is not None:
if not os.path.exists(prompt_wav_path):
raise FileNotFoundError(f"prompt_wav_path does not exist: {prompt_wav_path}")
if reference_wav_path is not None:
if not os.path.exists(reference_wav_path):
raise FileNotFoundError(f"reference_wav_path does not exist: {reference_wav_path}")
if (prompt_wav_path is None) != (prompt_text is None):
raise ValueError("prompt_wav_path and prompt_text must both be provided or both be None")
is_v2 = isinstance(self.tts_model, VoxCPM2Model)
if reference_wav_path is not None and not is_v2:
raise ValueError("reference_wav_path is only supported with VoxCPM2 models")
text = text.replace("\n", " ")
text = re.sub(r"\s+", " ", text)View on GitHub (pinned to f5a1c6a6b9)
Solutions
- Skip empty/blank inputs upstream before calling generate
- Coerce to stripped str and check truthiness first
- Log and continue in batch loops instead of failing the whole run
Example fix
# before
audio = model.generate(text=user_input)
# after
if not isinstance(user_input, str) or not user_input.strip():
raise ValueError("nothing to synthesize")
audio = model.generate(text=user_input) Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(text, str) or not text.strip():
raise ValueError("nothing to synthesize") Type guard
def is_synthesizable(text) -> bool:
return isinstance(text, str) and bool(text.strip()) Prevention
- Filter blank lines when batch-processing transcripts
- Treat None/empty text as a skip, not an error, in pipelines
When it happens
Trigger: Calling generate('') , generate(None), generate(' '), or passing bytes/a list instead of str.
Common situations: Feeding pipeline output where a transcript field is empty, iterating over a file with blank lines, or frontend data arriving untyped.
Related errors
- Expected string input, got {type(text)}
- Retry on bad cases is not supported in streaming mode, setti
- Retry on bad cases is not supported in streaming mode, setti
AI-assisted analysis of OpenBMB/VoxCPM@f5a1c6a6b9 (2026-08-27).
Data as JSON: /api/errors/35942fd1ffd6172f.
Report an issue: GitHub.