cjpais/Handy · error · anyhow::Error

Failed to load SenseVoice model {}: {}

Error message

Failed to load SenseVoice model {}: {}

What it means

Thrown when SenseVoiceModel::load cannot build the Int8-quantized SenseVoice ONNX session from the model files at model_path. transcribe-rs fails when the expected .onnx artifacts are missing/corrupt or ONNX Runtime cannot create the session (provider unavailable, OOM). Handy wraps the cause with the model_id, emits a loading_failed model-state-changed event for the UI, and returns the error from load_model.

Source

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

            EngineType::MoonshineStreaming => {
                let engine = StreamingModel::load(&model_path, 0, &Quantization::default())
                    .map_err(|e| {
                        let error_msg = format!(
                            "Failed to load moonshine streaming model {}: {}",
                            model_id, e
                        );
                        emit_loading_failed(&error_msg);
                        anyhow::anyhow!(error_msg)
                    })?;
                LoadedEngine::MoonshineStreaming(engine)
            }
            EngineType::SenseVoice => {
                let engine =
                    SenseVoiceModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                        let error_msg =
                            format!("Failed to load SenseVoice model {}: {}", model_id, e);
                        emit_loading_failed(&error_msg);
                        anyhow::anyhow!(error_msg)
                    })?;
                LoadedEngine::SenseVoice(engine)
            }
            EngineType::GigaAM => {
                let engine = GigaAMModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                    let error_msg = format!("Failed to load gigaam model {}: {}", model_id, e);
                    emit_loading_failed(&error_msg);
                    anyhow::anyhow!(error_msg)
                })?;
                LoadedEngine::GigaAM(engine)
            }
            EngineType::Canary => {
                let engine = CanaryModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                    let error_msg = format!("Failed to load canary model {}: {}", model_id, e);
                    emit_loading_failed(&error_msg);
                    anyhow::anyhow!(error_msg)
                })?;
                LoadedEngine::Canary(engine)

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Re-download SenseVoice from the model selector (remove the local copy first so ModelManager fetches fresh files)
  2. Verify the model directory's .onnx files exist and are non-empty (compare against the registry's expected sizes)
  3. Free disk space and check antivirus quarantine, then retry
  4. Load another engine (Whisper/Parakeet) to verify the shared ONNX runtime path works
  5. Update Handy to keep transcribe-rs/ort and downloaded artifacts in sync

Example fix

// before
let engine = SenseVoiceModel::load(&model_path, &Quantization::Int8);

// after — validate before loading and give a re-download hint
let artifacts = std::fs::read_dir(&model_path)?.filter_map(|e| e.ok()).collect::<Vec<_>>();
anyhow::ensure!(!artifacts.is_empty(), "SenseVoice model dir is empty: {} — re-download the model", model_path.display());
let engine = SenseVoiceModel::load(&model_path, &Quantization::Int8)?;
Defensive patterns

Strategy: validation

Validate before calling

// Verify SenseVoice Int8 artifacts exist and are non-trivial before load
let path = model_manager.get_model_path(model_id)?;
let total: u64 = std::fs::read_dir(&path)?
    .filter_map(|e| e.ok())
    .map(|e| e.metadata().map(|m| m.len()).unwrap_or(0))
    .sum();
anyhow::ensure!(total > 1_000_000, "SenseVoice artifacts suspiciously small ({} bytes) — re-download", total);

Try / catch

match tm.load_model(&model_id) {
    Err(e) if e.to_string().contains("Failed to load SenseVoice model") => {
        model_manager.remove_local_model(&model_id)?;
        tm.initiate_model_load(); // re-download + reload in background
    }
    other => { other?; }
}

Prevention

When it happens

Trigger: load_model() reaches EngineType::SenseVoice and SenseVoiceModel::load(&model_path, &Quantization::Int8) returns Err — missing/truncated Int8 ONNX files in the model directory, hash-mismatched artifacts, or an ort session-creation failure such as a missing execution provider or insufficient memory.

Common situations: Interrupted or partial model download; user or cleanup tool deleted files inside the models directory; AV false-positive quarantine of .onnx files; app update changed the ort/transcribe-rs version so previously downloaded SenseVoice artifacts no longer load; constrained-RAM devices.

Related errors


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