OpenBMB/VoxCPM · error · ValueError

prompt_wav_path and prompt_text must both be provided or bot

Error message

prompt_wav_path and prompt_text must both be provided or both be None

What it means

_generate requires prompt_wav_path and prompt_text to be supplied together (both present or both None); supplying exactly one raises ValueError. The prompt text is needed to transcribe-align the prompt audio for voice cloning.

Source

Thrown at src/voxcpm/core.py:240

            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)
        temp_files = []

        try:
            actual_prompt_path = prompt_wav_path
            actual_ref_path = reference_wav_path

            if denoise and self.denoiser is not None:
                if prompt_wav_path is not None:
                    with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp:
                        temp_files.append(tmp.name)
                    self.denoiser.enhance(prompt_wav_path, output_path=temp_files[-1])

View on GitHub (pinned to f5a1c6a6b9)

Solutions

  1. Pass both prompt_wav_path and prompt_text together
  2. Omit both for zero-shot synthesis without voice cloning
  3. Ensure defaults are None, not empty strings, when building kwargs dynamically

Example fix

# before
model.generate(text, prompt_wav_path="a.wav")
# after
model.generate(text, prompt_wav_path="a.wav", prompt_text="transcript of a.wav")
Defensive patterns

Strategy: type-guard

Validate before calling

if (prompt_wav_path is None) != (prompt_text is None):
    raise ValueError("prompt_wav_path and prompt_text must be passed together")

Type guard

def has_valid_prompt(wav, txt) -> bool:
    return (wav is None) == (txt is None)

Prevention

When it happens

Trigger: generate(text, prompt_wav_path='a.wav') without prompt_text, or prompt_text='...' without prompt_wav_path.

Common situations: Assuming the library can transcribe the prompt automatically, or optional-arg handling code that passes prompt_text='' (not None) alongside no wav.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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