{"record":{"id":"9894ea1e0aa5bc53","repo":"Zackriya-Solutions/meetily","slug":"failed-to-create-vad-session","errorCode":null,"errorMessage":"Failed to create VAD session: {:?}","messagePattern":"Failed to create VAD session: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/audio/vad.rs","lineNumber":62,"sourceCode":"        config.negative_speech_threshold = 0.35;  // Silero default - allows natural pauses\n\n        // CRITICAL FIX: Removed redemption_time capping to support long continuous speech\n        // Previous: capped at 400ms, causing VAD to fragment 5-second speech into 40ms segments\n        // New: Use full redemption_time from pipeline (2000ms) to bridge natural pauses\n        config.redemption_time = Duration::from_millis(redemption_time_ms as u64);\n        config.pre_speech_pad = Duration::from_millis(300);   // Pre-speech padding for context\n        config.post_speech_pad = Duration::from_millis(400);  // Increased: more context at end\n\n        // CRITICAL FIX: Increased min_speech_time to prevent tiny 40ms fragments\n        // Previous: 100ms allowed too-short segments that Whisper rejects\n        // New: 250ms ensures segments are substantial enough for Whisper (>100ms requirement)\n        config.min_speech_time = Duration::from_millis(250);  // Prevent tiny fragments\n\n        debug!(\"Creating VAD session with: sample_rate={}Hz, redemption={}ms, min_speech={}ms, input_rate={}Hz\",\n               VAD_SAMPLE_RATE, redemption_time_ms, 250, input_sample_rate);\n\n        let session = VadSession::new(config)\n            .map_err(|e| anyhow!(\"Failed to create VAD session: {:?}\", e))?;\n\n        // VAD uses 30ms chunks at 16kHz (480 samples)\n        let vad_chunk_size = (VAD_SAMPLE_RATE as f32 * 0.03) as usize; // 480 samples\n\n        info!(\"VAD processor created: input={}Hz, vad={}Hz, chunk_size={} samples\",\n              input_sample_rate, VAD_SAMPLE_RATE, vad_chunk_size);\n\n        Ok(Self {\n            session,\n            chunk_size: vad_chunk_size,\n            sample_rate: input_sample_rate, // Store input rate for resampling ratio in resample_to_16k()\n            buffer: Vec::with_capacity(vad_chunk_size * 2),\n            speech_segments: VecDeque::new(),\n            current_speech: Vec::new(),\n            in_speech: false,\n            processed_samples: 0,\n            speech_start_sample: 0,\n            // Initialize state tracking","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/vad.rs#L44-L80","documentation":"VadSession::new(config) failed while constructing the silero VAD session used to filter speech before Whisper. The session bundles an ONNX model plus the shown config (pads, min_speech_time, redemption), so construction fails on model/runtime problems or an invalid config combination - most notably a sample rate the model does not support.","triggerScenarios":"Creating VadProcessor with a config whose sample rate is not one the silero model supports (must be 16 kHz per VAD_SAMPLE_RATE), an ONNX runtime initialization failure (missing native libs in the packaged app), or a dependency version mismatch between the VAD crate and its bundled model.","commonSituations":"Bundling the app without required onnxruntime libraries; cargo update bumping the VAD/ort crates; passing an input rate that was not resampled to 16k as the pipeline expects.","solutions":["Verify audio is resampled to 16 kHz (VAD_SAMPLE_RATE) before constructing the processor","Pin/align the silero VAD and onnxruntime dependency versions (cargo tree -i) and rebuild","Reproduce VadSession::new with these exact config values in a minimal binary outside the app","Check the packaged app ships the ONNX runtime native libraries"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Smoke-test VAD construction at app startup so failures surface at boot, not mid-recording\nfn vad_constructs() -> bool {\n    let mut config = VadConfig::new();\n    config.sample_rate = VAD_SAMPLE_RATE;\n    VadSession::new(config).is_ok()\n}","typeGuard":null,"tryCatchPattern":"let session = VadSession::new(config).map_err(|e| anyhow!(\n    \"Failed to create VAD session: {e:?} (sample_rate={}Hz, input={}Hz)\",\n    VAD_SAMPLE_RATE, input_sample_rate\n))?;","preventionTips":["Construct the VAD session once at startup to fail fast","Pin VAD/onnxruntime crate versions in Cargo.lock","Verify packaged builds include ONNX runtime native libraries"],"tags":["vad","silero","onnx","audio","init"],"backgroundTag":"vad-session-init-failed","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}