{"record":{"id":"973ee9b0474badcf","repo":"cjpais/Handy","slug":"failed-to-load-moonshine-model","errorCode":null,"errorMessage":"Failed to load moonshine model {}: {}","messagePattern":"Failed to load moonshine model (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/transcription.rs","lineNumber":632,"sourceCode":"                let engine =\n                    ParakeetModel::load(&model_path, &Quantization::Int8).map_err(|e| {\n                        let error_msg =\n                            format!(\"Failed to load parakeet model {}: {}\", model_id, e);\n                        emit_loading_failed(&error_msg);\n                        anyhow::anyhow!(error_msg)\n                    })?;\n                LoadedEngine::Parakeet(engine)\n            }\n            EngineType::Moonshine => {\n                let engine = MoonshineModel::load(\n                    &model_path,\n                    MoonshineVariant::Base,\n                    &Quantization::default(),\n                )\n                .map_err(|e| {\n                    let error_msg = format!(\"Failed to load moonshine model {}: {}\", model_id, e);\n                    emit_loading_failed(&error_msg);\n                    anyhow::anyhow!(error_msg)\n                })?;\n                LoadedEngine::Moonshine(engine)\n            }\n            EngineType::MoonshineStreaming => {\n                let engine = StreamingModel::load(&model_path, 0, &Quantization::default())\n                    .map_err(|e| {\n                        let error_msg = format!(\n                            \"Failed to load moonshine streaming model {}: {}\",\n                            model_id, e\n                        );\n                        emit_loading_failed(&error_msg);\n                        anyhow::anyhow!(error_msg)\n                    })?;\n                LoadedEngine::MoonshineStreaming(engine)\n            }\n            EngineType::SenseVoice => {\n                let engine =\n                    SenseVoiceModel::load(&model_path, &Quantization::Int8).map_err(|e| {","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/cjpais/Handy/blob/98a4d80cce8ad41efec2a419b59d9e81229a35d7/src-tauri/src/managers/transcription.rs#L614-L650","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Verify the model files on disk: the directory must contain the expected non-empty .onnx files matching the registry's advertised size","Check free disk space and antivirus/quarantine history before re-downloading","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","Update Handy so the bundled transcribe-rs/ort version matches the model artifacts it downloads"],"exampleFix":"// before\nlet engine = MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default());\n\n// after — pre-validate the artifacts so the user gets an actionable message instead of a raw ORT error\nfor file in expected_moonshine_files(&model_path) {\n    let len = std::fs::metadata(&file)\n        .with_context(|| format!(\"model artifact missing: {}\", file.display()))?\n        .len();\n    anyhow::ensure!(len > 0, \"model artifact is empty (truncated download): {}\", file.display());\n}\nlet engine = MoonshineModel::load(&model_path, MoonshineVariant::Base, &Quantization::default())?;","handlingStrategy":"validation","validationCode":"// Before triggering a Moonshine load, confirm the artifacts are present and non-empty\nlet path = model_manager.get_model_path(model_id)?;\nlet files = std::fs::read_dir(&path)?.filter_map(|e| e.ok()).collect::<Vec<_>>();\nanyhow::ensure!(!files.is_empty(), \"model dir empty: {} — re-download {}\", path.display(), model_id);\nfor f in files {\n    let len = f.metadata()?.len();\n    anyhow::ensure!(len > 0, \"empty artifact: {} — re-download the model\", f.path().display());\n}","typeGuard":null,"tryCatchPattern":"match tm.load_model(&model_id) {\n    Ok(()) => {}\n    Err(e) if e.to_string().contains(\"Failed to load moonshine model\") => {\n        // loading_failed event already emitted; recover by re-downloading or switching models\n        model_manager.remove_local_model(&model_id)?;\n        tm.load_model(&fallback_model_id)?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Let model downloads finish completely before switching models or quitting the app","Verify free disk space before large downloads and keep the models directory untouched by cleanup tools","Exclude the app's models directory from antivirus real-time scanning or restore quarantined .onnx files promptly","After every Handy update, re-download ONNX models if loads begin failing (artifact/runtime version skew)"],"tags":["rust","tauri","onnx","model-loading","moonshine","transcribe-rs"],"backgroundTag":"onnx-model-load-failed","analyzedSha":"98a4d80cce8ad41efec2a419b59d9e81229a35d7","analyzedAt":"2026-08-16T20:58:09.966Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}