{"record":{"id":"35942fd1ffd6172f","repo":"OpenBMB/VoxCPM","slug":"target-text-must-be-a-non-empty-string","errorCode":null,"errorMessage":"target text must be a non-empty string","messagePattern":"target text must be a non-empty string","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/voxcpm/core.py","lineNumber":229,"sourceCode":"            cfg_value: Guidance scale for the generation model.\n            inference_timesteps: Number of inference steps.\n            min_len: Minimum audio length.\n            max_len: Maximum token length during generation.\n            normalize: Whether to run text normalization before generation.\n            denoise: Whether to denoise the prompt/reference audio if a\n                denoiser is available.\n            retry_badcase: Whether to retry badcase.\n            retry_badcase_max_times: Maximum number of times to retry badcase.\n            retry_badcase_ratio_threshold: Threshold for audio-to-text ratio.\n            streaming: Whether to return a generator of audio chunks.\n            seed: Optional random seed for reproducibility.\n        Returns:\n            Generator of numpy.ndarray: 1D waveform array (float32) on CPU.\n            Yields audio chunks for each generation step if ``streaming=True``,\n            otherwise yields a single array containing the final audio.\n        \"\"\"\n        if not isinstance(text, str) or not text.strip():\n            raise ValueError(\"target text must be a non-empty string\")\n\n        if prompt_wav_path is not None:\n            if not os.path.exists(prompt_wav_path):\n                raise FileNotFoundError(f\"prompt_wav_path does not exist: {prompt_wav_path}\")\n\n        if reference_wav_path is not None:\n            if not os.path.exists(reference_wav_path):\n                raise FileNotFoundError(f\"reference_wav_path does not exist: {reference_wav_path}\")\n\n        if (prompt_wav_path is None) != (prompt_text is None):\n            raise ValueError(\"prompt_wav_path and prompt_text must both be provided or both be None\")\n\n        is_v2 = isinstance(self.tts_model, VoxCPM2Model)\n        if reference_wav_path is not None and not is_v2:\n            raise ValueError(\"reference_wav_path is only supported with VoxCPM2 models\")\n\n        text = text.replace(\"\\n\", \" \")\n        text = re.sub(r\"\\s+\", \" \", text)","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/OpenBMB/VoxCPM/blob/f5a1c6a6b901bc732e20f0d59a369f6829ad717a/src/voxcpm/core.py#L211-L247","documentation":"_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.","triggerScenarios":"Calling generate('') , generate(None), generate('   '), or passing bytes/a list instead of str.","commonSituations":"Feeding pipeline output where a transcript field is empty, iterating over a file with blank lines, or frontend data arriving untyped.","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"],"exampleFix":"# before\naudio = model.generate(text=user_input)\n# after\nif not isinstance(user_input, str) or not user_input.strip():\n    raise ValueError(\"nothing to synthesize\")\naudio = model.generate(text=user_input)","handlingStrategy":"type-guard","validationCode":"if not isinstance(text, str) or not text.strip():\n    raise ValueError(\"nothing to synthesize\")","typeGuard":"def is_synthesizable(text) -> bool:\n    return isinstance(text, str) and bool(text.strip())","tryCatchPattern":null,"preventionTips":["Filter blank lines when batch-processing transcripts","Treat None/empty text as a skip, not an error, in pipelines"],"tags":["input-validation","tts","empty-input"],"backgroundTag":"empty-input-validation","analyzedSha":"f5a1c6a6b901bc732e20f0d59a369f6829ad717a","analyzedAt":"2026-08-27T05:54:30.617Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}