Hmbown/CodeWhale · error · anyhow::Error

Speech text cannot be empty

Error message

Speech text cannot be empty

What it means

Basic input guard in the speech command: after the provider check it trims the text argument and refuses whitespace-only input. A TTS request with empty text is meaningless (and would fail server-side), so the CLI rejects it before touching the network or inferring a model.

Source

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

        output_dir,
        model,
        voice,
        instruction,
        voice_prompt,
        clone_voice,
        format,
        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(", ")

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Pass a non-empty text string — leading/trailing whitespace alone is not enough
  2. If text comes from a variable, assert it is set and non-blank before invoking
  3. When text is generated, check the generator/template that produced the blank output

Example fix

// before
TEXT=""
codewhale speech --text "$TEXT"   # bails: Speech text cannot be empty

// after
TEXT="Build 42 finished"
[ -n "$(printf '%s' "$TEXT" | tr -d '[:space:]')" ] && codewhale speech --text "$TEXT"
Defensive patterns

Strategy: validation

Validate before calling

# reject blank text before calling the CLI
[ -n "$(printf '%s' "$TEXT" | tr -d '[:space:]')" ] || { echo 'speech text is blank' >&2; exit 2; }
codewhale speech --text "$TEXT"

Prevention

When it happens

Trigger: Invoking `codewhale speech` with a text argument that is empty or only whitespace (text.trim().is_empty()).

Common situations: Passing an unset shell variable (empty after expansion); scripts generating text from a template that rendered blank; copy-paste losing the quoted argument.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/2759cadf1866c5ec. Report an issue: GitHub.