{"record":{"id":"9cc9d7f9d9c9a446","repo":"cjpais/Handy","slug":"failed-to-create-silerovad","errorCode":null,"errorMessage":"Failed to create SileroVad: {}","messagePattern":"Failed to create SileroVad: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/audio.rs","lineNumber":272,"sourceCode":"#[derive(Debug, Default, Clone, Copy)]\nstruct MuteState {\n    did_mute: bool,\n    prev_muted: Option<bool>,\n}\n\n/* ──────────────────────────────────────────────────────────────── */\n\nfn create_audio_recorder(\n    vad_path: &Path,\n    app_handle: &tauri::AppHandle,\n    selected_channel: Option<u16>,\n    stream_router: Arc<StreamRouter>,\n) -> Result<AudioRecorder, anyhow::Error> {\n    // A single Silero engine covers both the offline and streaming policies (never\n    // active at once within a recording), so the recorder reconfigures its\n    // hangover tail per session rather than keeping two ONNX sessions resident.\n    let silero = SileroVad::new(vad_path, VAD_THRESHOLD)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create SileroVad: {}\", e))?;\n    let smoothed_vad = SmoothedVad::new(\n        Box::new(silero),\n        VAD_PREFILL_FRAMES,\n        VAD_OFFLINE_HANGOVER_FRAMES,\n        VAD_ONSET_FRAMES,\n    );\n\n    // Recorder with VAD, a spectrum-level callback that forwards level updates to\n    // the frontend, and an audio-frame callback that feeds live streaming via a\n    // shared `StreamRouter` (captured directly, not via Tauri state — see its docs).\n    let recorder = AudioRecorder::new()\n        .map_err(|e| anyhow::anyhow!(\"Failed to create AudioRecorder: {}\", e))?\n        .with_vad(\n            Box::new(smoothed_vad),\n            VAD_OFFLINE_HANGOVER_FRAMES,\n            VAD_STREAMING_HANGOVER_FRAMES,\n        )\n        .with_selected_channel(selected_channel)","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/cjpais/Handy/blob/98a4d80cce8ad41efec2a419b59d9e81229a35d7/src-tauri/src/managers/audio.rs#L254-L290","documentation":"Thin wrapper in create_audio_recorder (audio.rs:272) around SileroVad::new. The message carries the inner cause via {e}, so it fires for exactly two reasons: the threshold range check (errors[0]) or ONNX session creation (errors[1]). In this codebase the threshold is the fixed VAD_THRESHOLD constant, so real occurrences are almost always the ONNX/VAD engine failing to load the Silero model.","triggerScenarios":"preload_vad() resolving resources/models/silero_vad_v4.onnx to a path where the file is missing or corrupt; ONNX Runtime unable to initialize in the packaged app because the model was not bundled.","commonSituations":"Same as the underlying Vad::new failure: skipped dev setup step, unbundled resource, broken onnxruntime libs. Only appears at recording setup time (first recording or preload), so the app starts fine and fails later.","solutions":["Read the appended {e} to see which inner failure it is (threshold vs 'Failed to create VAD')","If it is the inner VAD failure, verify/re-download silero_vad_v4.onnx (see error[1])","If VAD_THRESHOLD was modified, confirm it is within 0.0..=1.0","For packaged builds, confirm the model ships inside the bundle resources"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let recorder = create_audio_recorder(&vad_path, &app, channel, router)\n    .context(\"failed to build audio recorder\"); // {e} chains the inner SileroVad cause","preventionTips":["Treat this as a pass-through: always read the chained cause, fix the inner error","Call preload_vad() eagerly at startup so a broken VAD model fails fast with one clear message"],"tags":["rust","vad","wrapper","initialization"],"backgroundTag":"vad-initialization-failed","analyzedSha":"98a4d80cce8ad41efec2a419b59d9e81229a35d7","analyzedAt":"2026-08-16T20:58:09.966Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}