cjpais/Handy · error · anyhow::Error

Failed to load moonshine streaming model {}: {}

Error message

Failed to load moonshine streaming model {}: {}

What it means

Thrown when StreamingModel::load fails to create the streaming Moonshine engine from the model files at model_path. Streaming Moonshine needs its own streaming ONNX artifacts; if they are absent, corrupt, or incompatible with the bundled ort, session creation errors and Handy aborts the load. As with the other engines, emit_loading_failed broadcasts a loading_failed model-state-changed event and the error is returned from load_model with the model_id and cause attached.

Source

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

                    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| {
                        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)

View on GitHub (pinned to 98a4d80cce)

Solutions

  1. Delete and re-download the moonshine streaming model via the model selector so ModelManager replaces the artifacts
  2. Confirm the model directory contains the streaming ONNX files and they are non-zero length
  3. Check disk space and security-software quarantine before re-downloading
  4. Try the non-streaming Moonshine or a Whisper model to isolate whether only the streaming artifacts are broken
  5. Update Handy so runtime and downloaded artifacts stay version-matched

Example fix

// before
let engine = StreamingModel::load(&model_path, 0, &Quantization::default());

// after — surface an actionable failure and schedule a clean re-download
let engine = match StreamingModel::load(&model_path, 0, &Quantization::default()) {
    Ok(engine) => engine,
    Err(e) => {
        emit_loading_failed(&format!("Failed to load moonshine streaming model {}: {}", model_id, e));
        self.model_manager.remove_local_model(model_id)?; // force fresh download next attempt
        return Err(anyhow::anyhow!("moonshine streaming model corrupt, re-download scheduled: {}", e));
    }
};
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the streaming model pack has its ONNX files before loading
let path = model_manager.get_model_path(model_id)?;
let onnx: Vec<_> = std::fs::read_dir(&path)?
    .filter_map(|e| e.ok())
    .filter(|e| e.path().extension().map_or(false, |x| x == "onnx"))
    .collect();
anyhow::ensure!(!onnx.is_empty() && onnx.iter().all(|e| e.metadata().map(|m| m.len() > 0).unwrap_or(false)),
    "streaming model artifacts incomplete under {} — re-download", path.display());

Try / catch

match tm.load_model(&model_id) {
    Err(e) if e.to_string().contains("Failed to load moonshine streaming model") => {
        model_manager.remove_local_model(&model_id)?; // clear bad artifacts
        tm.load_model(&model_id)? // retry once with a fresh download
    }
    other => other?,
}

Prevention

When it happens

Trigger: load_model() hits EngineType::MoonshineStreaming and StreamingModel::load(&model_path, 0, &Quantization::default()) errors: the downloaded model pack is missing the streaming variant files, files are truncated from an interrupted download, or ort cannot allocate/create the session (missing execution provider, low memory).

Common situations: Partial download of the moonshine streaming model pack; disk-full during fetch; AV quarantine of .onnx files; version skew between cached model artifacts and a newly bundled transcribe-rs/ort after an app update; low-memory machines where Int8/default quantization still exceeds available RAM.

Related errors


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