Hmbown/CodeWhale · error · anyhow::Error

Use either --clone-voice or --voice for cloned voice data…

Error message

Use either --clone-voice or --voice for cloned voice data, not both

What it means

The speech subcommand accepts cloned-voice audio either as --clone-voice (a file path) or as --voice (a data:audio/ URI); supplying both is ambiguous, so it bails. Exactly one voice-source mechanism must be used.

Solutions

  1. Remove either --clone-voice or --voice, keeping only one voice source
  2. If you have a file, use --clone-voice; if you already have a data URI, use --voice
  3. Fix scripts so the voice-source flag is set in exactly one branch

Example fix

// before
codewhale speech --clone-voice sample.wav --voice "data:audio/wav;base64,..."
// after
codewhale speech --clone-voice sample.wav
Defensive patterns

Strategy: validation

Validate before calling

if clone_voice.is_some() && voice.is_some() {
    eprintln!("use either --clone-voice or --voice, not both");
    std::process::exit(2);
}

Prevention

When it happens

Trigger: Running `speech` with both --clone-voice <path> and --voice <data-uri> set (clone_voice.is_some() && voice.is_some()).

Common situations: Scripts that append --voice conditionally while --clone-voice is already present; combining an old command line with a new flag; documentation examples copied together.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/95cf9463641eb0f5. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:7818

        json: json_output,
    } = args;

    if config.api_provider() != ApiProvider::XiaomiMimo {
        bail!(
            "`speech` requires provider = \"xiaomi-mimo\" (current: {}). Run with `--provider xiaomi-mimo` or set it in config.",
            config.api_provider().as_str()
        );
    }

    if text.trim().is_empty() {
        bail!("Speech text cannot be empty");
    }
    let voice_is_data_uri = voice
        .as_deref()
        .map(str::trim)
        .is_some_and(|value| value.starts_with("data:audio/"));
    if clone_voice.is_some() && voice.is_some() {
        bail!("Use either --clone-voice or --voice for cloned voice data, not both");
    }
    let model = infer_speech_model(
        model.as_deref(),
        clone_voice.is_some() || voice_is_data_uri,
        voice_prompt.is_some(),
    );
    let model_lower = model.to_ascii_lowercase();
    if !model_lower.contains("tts") {
        bail!(
            "speech requires a TTS model (examples: {}); got {model}",
            SPEECH_MODEL_EXAMPLES.join(", ")
        );
    }
    let is_voice_design = model_lower.contains("voicedesign");
    let is_voice_clone = model_lower.contains("voiceclone");

    let instruction = combine_speech_instructions(instruction, voice_prompt);
    if is_voice_design

View on GitHub (pinned to 73e0f67d83)