Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(windows): use native Silero VAD frame size and lower speech threshold

louis030195c99c3967882f
diff --git a/crates/screenpipe-audio/src/speaker/prepare_segments.rs b/crates/screenpipe-audio/src/speaker/prepare_segments.rs
index 98762959d..fbc60cb49 100644
--- a/crates/screenpipe-audio/src/speaker/prepare_segments.rs
+++ b/crates/screenpipe-audio/src/speaker/prepare_segments.rs
@@ -24,6 +24,13 @@ pub async fn prepare_segments(
) -> Result<(tokio::sync::mpsc::Receiver<SpeechSegment>, bool, f32)> {
let audio_data = normalize_v2(audio_data);
+ // Silero VAD v5 expects continuous 512-sample chunks at 16kHz (32ms).
+ // On Windows, WASAPI delivers lower audio levels than CoreAudio, so we
+ // must feed Silero at its native frame size to preserve its LSTM temporal
+ // state — using 1600 caused 68ms gaps that broke speech detection.
+ #[cfg(target_os = "windows")]
+ let frame_size = 512;
+ #[cfg(not(target_os = "windows"))]
let frame_size = 1600;
let vad_engine = vad_engine.clone();
diff --git a/crates/screenpipe-audio/src/vad/mod.rs b/crates/screenpipe-audio/src/vad/mod.rs
index 43d09a818..f74205e5c 100644
--- a/crates/screenpipe-audio/src/vad/mod.rs
+++ b/crates/screenpipe-audio/src/vad/mod.rs
@@ -37,6 +37,12 @@ pub trait VadEngine: Send {
}
const FRAME_HISTORY: usize = 10; // Number of frames to consider for decision
+// On Windows, WASAPI captures at lower levels than CoreAudio, so Silero
+// returns lower speech probabilities for the same audio. Use a relaxed
+// threshold to avoid missing speech entirely.
+#[cfg(target_os = "windows")]
+const SPEECH_THRESHOLD: f32 = 0.3;
+#[cfg(not(target_os = "windows"))]
const SPEECH_THRESHOLD: f32 = 0.5;
const SILENCE_THRESHOLD: f32 = 0.35;
const SPEECH_FRAME_THRESHOLD: usize = 3; // Minimum number of frames above SPEECH_THRESHOLD to consider as speech