cjpais/Handy · error · anyhow::Error

Failed to load moonshine model {}: {}

Error message

Failed to load moonshine model {}: {}

What it means

Thrown when transcribe-rs's MoonshineModel::load fails to build the ONNX Runtime session for the Moonshine Base model at model_path. The load fails when the expected encoder/decoder .onnx artifacts are missing, truncated, or incompatible with the bundled ort version (bad session creation, missing execution provider, out of memory). Handy wraps the cause, emits a model-state-changed/loading_failed Tauri event so the UI model selector shows the failure, and aborts load_model leaving no engine loaded.

Source

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

                let engine =
                    ParakeetModel::load(&model_path, &Quantization::Int8).map_err(|e| {
                        let error_msg =
                            format!("Failed to load parakeet model {}: {}", model_id, e);
                        emit_loading_failed(&error_msg);
                        anyhow::anyhow!(error_msg)
                    })?;
                LoadedEngine::Parakeet(engine)
            }
            EngineType::Moonshine => {
                let engine = MoonshineModel::load(
                    &model_path,
                    MoonshineVariant::Base,
                    &Quantization::default(),
                )
                .map_err(|e| {
                    let error_msg = format!("Failed to load moonshine model {}: {}", model_id, e);
                    emit_loading_failed(&error_msg);
                    anyhow::anyhow!(error_msg)
                })?;
                LoadedEngine::Moonshine(engine)
            }
            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| {

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Re-download the model: remove it in the model selector (or delete its folder under the models dir) so ModelManager re-fetches it, then reload
  2. Verify the model files on disk: the directory must contain the expected non-empty .onnx files matching the registry's advertised size
  3. Check free disk space and antivirus/quarantine history before re-downloading
  4. Load a different engine (e.g. a Whisper model) to confirm the ONNX runtime itself is healthy — if that also fails, it is an environment problem, not the model
  5. Update Handy so the bundled transcribe-rs/ort version matches the model artifacts it downloads

Example fix

// before
let engine = MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default());

// after — pre-validate the artifacts so the user gets an actionable message instead of a raw ORT error
for file in expected_moonshine_files(&model_path) {
    let len = std::fs::metadata(&file)
        .with_context(|| format!("model artifact missing: {}", file.display()))?
        .len();
    anyhow::ensure!(len > 0, "model artifact is empty (truncated download): {}", file.display());
}
let engine = MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default())?;
Defensive patterns

Strategy: validation

Validate before calling

// Before triggering a Moonshine load, confirm the artifacts are present and non-empty
let path = model_manager.get_model_path(model_id)?;
let files = std::fs::read_dir(&path)?.filter_map(|e| e.ok()).collect::<Vec<_>>();
anyhow::ensure!(!files.is_empty(), "model dir empty: {} — re-download {}", path.display(), model_id);
for f in files {
    let len = f.metadata()?.len();
    anyhow::ensure!(len > 0, "empty artifact: {} — re-download the model", f.path().display());
}

Try / catch

match tm.load_model(&model_id) {
    Ok(()) => {}
    Err(e) if e.to_string().contains("Failed to load moonshine model") => {
        // loading_failed event already emitted; recover by re-downloading or switching models
        model_manager.remove_local_model(&model_id)?;
        tm.load_model(&fallback_model_id)?;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: load_model() reaches EngineType::Moonshine and MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default()) returns Err: model directory lacks the Base-variant ONNX files, a download was interrupted leaving 0-byte/partial files, ort cannot create a session (missing provider DLL/so, insufficient RAM), or the cached artifacts were built for a different transcribe-rs version.

Common situations: First-run download interrupted or disk full; antivirus quarantining .onnx files; user manually deleting files under the app's models directory; upgrading Handy brings a new transcribe-rs/ort that rejects previously cached Moonshine artifacts; running on a machine below the model's memory requirements.

Related errors


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