cjpais/Handy · error · anyhow::Error

SenseVoice transcription failed: {}

Error message

SenseVoice transcription failed: {}

What it means

SenseVoiceModel::transcribe_with failed during ONNX inference. Handy builds SenseVoiceParams { language (zh/en/ja/ko/yue or None from normalize_cjk_language), use_itn: true } and the transcribe-rs call returns an ONNX Runtime error: session run failure, provider fault, unsupported language tensor, degenerate audio length, or corrupted Int8 artifacts. The engine stays loaded after the error (return_engine runs on the normal-error path).

Source

Thrown at src-tauri/src/managers/transcription.rs:1366

                        }),
                    LoadedEngine::SenseVoice(sense_voice_engine) => {
                        let language = match normalize_cjk_language(&validated_language) {
                            "zh" => Some("zh".to_string()),
                            "en" => Some("en".to_string()),
                            "ja" => Some("ja".to_string()),
                            "ko" => Some("ko".to_string()),
                            "yue" => Some("yue".to_string()),
                            _ => None,
                        };
                        applied_language_hint = language.clone();
                        let params = SenseVoiceParams {
                            language,
                            use_itn: Some(true),
                        };
                        sense_voice_engine
                            .transcribe_with(&audio, &params)
                            .map(|r| r.text)
                            .map_err(|e| anyhow::anyhow!("SenseVoice transcription failed: {}", e))
                    }
                    LoadedEngine::GigaAM(gigaam_engine) => gigaam_engine
                        .transcribe(&audio, &TranscribeOptions::default())
                        .map(|r| r.text)
                        .map_err(|e| anyhow::anyhow!("GigaAM transcription failed: {}", e)),
                    LoadedEngine::Canary(canary_engine) => {
                        output_was_translated = settings.translate_to_english;
                        let lang = if validated_language == "auto" {
                            None
                        } else {
                            Some(validated_language.clone())
                        };
                        applied_language_hint = lang.clone();
                        let options = TranscribeOptions {
                            language: lang,
                            translate: settings.translate_to_english,
                            ..Default::default()
                        };

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Retry with a longer, clean recording
  2. Re-download the SenseVoice model if failures repeat
  3. Free memory/VRAM and close competing GPU apps
  4. Test with language set to auto to rule out language-head issues
  5. Update Handy for ort/transcribe-rs compatibility

Example fix

// before
sense_voice_engine.transcribe_with(&audio, &params).map_err(|e| anyhow::anyhow!("SenseVoice transcription failed: {}", e))?;

// after — retry once without language hint if the hinted run fails (rules out language-head issues)
let r = match sense_voice_engine.transcribe_with(&audio, &params) {
    Ok(r) => r,
    Err(e) if params.language.is_some() => {
        warn!("SenseVoice failed with language hint ({}), retrying auto", e);
        sense_voice_engine.transcribe_with(&audio, &SenseVoiceParams::default())?
    }
    Err(e) => return Err(anyhow::anyhow!("SenseVoice transcription failed: {}", e)),
};
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate audio length and finiteness; note language is limited to zh/en/ja/ko/yue or auto
anyhow::ensure!(audio.len() >= 1600, "audio too short for SenseVoice");
anyhow::ensure!(audio.iter().all(|s| s.is_finite()), "non-finite audio");

Try / catch

match tm.transcribe(audio.clone()) {
    Err(e) if e.to_string().contains("SenseVoice transcription failed") && language != "auto" => {
        set_language("auto"); tm.transcribe(audio) // drop the hint and retry
    }
    Err(e) if e.to_string().contains("SenseVoice transcription failed") => reDownloadModel_and_retry(&model_id, audio),
    other => other,
}

Prevention

When it happens

Trigger: sense_voice_engine.transcribe_with(&audio, &params) errors: ORT session run failure; audio too short after VAD; GPU execution-provider failure; corrupted/missing Int8 model files; memory exhaustion.

Common situations: Short recordings trimmed to near-nothing by VAD; AV quarantine or partial download of the SenseVoice pack; provider DLL/so issues after update; multilingual selections (the zh/en/ja/ko/yue mapping) combined with a model build lacking the language head.

Related errors


AI-assisted analysis of cjpais/Handy@98a4d80cce (2026-08-16). Data as JSON: /api/errors/b4c14bbb097145ce. Report an issue: GitHub.