{"record":{"id":"419854a3dca8d677","repo":"cjpais/Handy","slug":"silero-vad-error-e","errorCode":null,"errorMessage":"Silero VAD error: {e}","messagePattern":"Silero VAD error: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/audio_toolkit/vad/silero.rs","lineNumber":44,"sourceCode":"                .map_err(|e| anyhow::anyhow!(\"Failed to create VAD: {e}\"))?,\n            threshold,\n        })\n    }\n}\n\nimpl VoiceActivityDetector for SileroVad {\n    fn push_frame<'a>(&'a mut self, frame: &'a [f32]) -> Result<VadFrame<'a>> {\n        if frame.len() != SILERO_FRAME_SAMPLES {\n            anyhow::bail!(\n                \"expected {SILERO_FRAME_SAMPLES} samples, got {}\",\n                frame.len()\n            );\n        }\n\n        let result = self\n            .engine\n            .compute(frame)\n            .map_err(|e| anyhow::anyhow!(\"Silero VAD error: {e}\"))?;\n\n        if result.prob > self.threshold {\n            Ok(VadFrame::Speech(frame))\n        } else {\n            Ok(VadFrame::Noise)\n        }\n    }\n\n    fn frame_samples(&self) -> usize {\n        SILERO_FRAME_SAMPLES\n    }\n\n    fn reset(&mut self) {\n        // Clear the Silero LSTM hidden/cell state so a new session doesn't\n        // inherit recurrent context from the previous recording.\n        self.engine.reset();\n    }\n}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/cjpais/Handy/blob/c6fa60da2f13a5af660fba17f37af548855119c5/src-tauri/src/audio_toolkit/vad/silero.rs#L26-L62","documentation":"Wraps an error from the Silero ONNX inference call (engine.compute(frame)) during per-frame voice activity detection. The frame length is validated first, so this error means the ONNX session itself failed to execute — typically a corrupted model, a runtime/provider failure, or the LSTM state getting into a bad state after an I/O or session error. It surfaces mid-recording, one 512-sample frame at a time.","triggerScenarios":"Calling SileroVad::push_frame() when the ONNX runtime session errors during compute: model file corrupted on disk, ONNX runtime version/provider mismatch, or engine state invalidated after a previous partial failure.","commonSituations":"Disk corruption or a truncated silero_vad_v4.onnx that loaded but fails on inference; an ONNX runtime upgraded to an incompatible version; the model resource swapped/modified while the app is running; rare provider-level failures under memory pressure.","solutions":["Re-download silero_vad_v4.onnx and restart the app — a compute failure almost always traces to a damaged model file.","If it recurs, pin/reinstall the onnxruntime version used by the vad-rs dependency (check Cargo.lock for version drift).","Check system memory and disk health; ONNX execution allocates arenas that can fail under pressure.","Call reset() on the VAD between recording sessions (the code does this) to avoid carrying bad recurrent state forward."],"exampleFix":"// before\nlet frame = vad.push_frame(samples)?;\n\n// after — treat a VAD compute failure as session-poisoned: reset once, then surface\nmatch vad.push_frame(samples) {\n    Ok(frame) => frame,\n    Err(e) => {\n        warn!(\"VAD compute failed ({e}); resetting session state\");\n        vad.reset();\n        return Err(e);\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let frame = match vad.push_frame(chunk) {\n    Ok(f) => f,\n    Err(e) => {\n        // session may be poisoned: reset state, drop this recording\n        vad.reset();\n        return Err(anyhow::anyhow!(\"VAD compute failed; session reset: {e}\"));\n    }\n};","preventionTips":["Call reset() between recording sessions so bad recurrent state never carries over.","Keep the .onnx model file read-only after download to prevent accidental corruption.","Log the frame index when compute fails — repeated failures at frame 0 point to a corrupt model.","Verify the model hash once at startup rather than discovering corruption mid-recording."],"tags":["vad","silero","onnx","inference","recording"],"backgroundTag":"onnx-inference-error","analyzedSha":"c6fa60da2f13a5af660fba17f37af548855119c5","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}