Zackriya-Solutions/meetily · error · anyhow::Error
Failed to create VAD session: {:?}
Error message
Failed to create VAD session: {:?} What it means
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.
Source
Thrown at frontend/src-tauri/src/audio/vad.rs:62
config.negative_speech_threshold = 0.35; // Silero default - allows natural pauses
// CRITICAL FIX: Removed redemption_time capping to support long continuous speech
// Previous: capped at 400ms, causing VAD to fragment 5-second speech into 40ms segments
// New: Use full redemption_time from pipeline (2000ms) to bridge natural pauses
config.redemption_time = Duration::from_millis(redemption_time_ms as u64);
config.pre_speech_pad = Duration::from_millis(300); // Pre-speech padding for context
config.post_speech_pad = Duration::from_millis(400); // Increased: more context at end
// CRITICAL FIX: Increased min_speech_time to prevent tiny 40ms fragments
// Previous: 100ms allowed too-short segments that Whisper rejects
// New: 250ms ensures segments are substantial enough for Whisper (>100ms requirement)
config.min_speech_time = Duration::from_millis(250); // Prevent tiny fragments
debug!("Creating VAD session with: sample_rate={}Hz, redemption={}ms, min_speech={}ms, input_rate={}Hz",
VAD_SAMPLE_RATE, redemption_time_ms, 250, input_sample_rate);
let session = VadSession::new(config)
.map_err(|e| anyhow!("Failed to create VAD session: {:?}", e))?;
// VAD uses 30ms chunks at 16kHz (480 samples)
let vad_chunk_size = (VAD_SAMPLE_RATE as f32 * 0.03) as usize; // 480 samples
info!("VAD processor created: input={}Hz, vad={}Hz, chunk_size={} samples",
input_sample_rate, VAD_SAMPLE_RATE, vad_chunk_size);
Ok(Self {
session,
chunk_size: vad_chunk_size,
sample_rate: input_sample_rate, // Store input rate for resampling ratio in resample_to_16k()
buffer: Vec::with_capacity(vad_chunk_size * 2),
speech_segments: VecDeque::new(),
current_speech: Vec::new(),
in_speech: false,
processed_samples: 0,
speech_start_sample: 0,
// Initialize state trackingView on GitHub (pinned to 0281737d87)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Smoke-test VAD construction at app startup so failures surface at boot, not mid-recording
fn vad_constructs() -> bool {
let mut config = VadConfig::new();
config.sample_rate = VAD_SAMPLE_RATE;
VadSession::new(config).is_ok()
} Try / catch
let session = VadSession::new(config).map_err(|e| anyhow!(
"Failed to create VAD session: {e:?} (sample_rate={}Hz, input={}Hz)",
VAD_SAMPLE_RATE, input_sample_rate
))?; Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- VAD task panicked: {}
- No speech detected in audio file
- Parakeet transcription failed on segment {}: {}
- VAD processing failed: {}
- No audio samples decoded from file
AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16).
Data as JSON: /api/errors/9894ea1e0aa5bc53.
Report an issue: GitHub.