From c49f0b43574a23a849428948a89a7ef4f77c1f9e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 17:47:36 +0000 Subject: [PATCH] fix: suppress common whisper hallucinations during silence Co-Authored-By: john@hyprnote.com --- crates/whisper-local/src/model/actual.rs | 51 +++++++++++++++++++----- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/crates/whisper-local/src/model/actual.rs b/crates/whisper-local/src/model/actual.rs index bc1577707b..e392e6fa81 100644 --- a/crates/whisper-local/src/model/actual.rs +++ b/crates/whisper-local/src/model/actual.rs @@ -231,19 +231,50 @@ impl Whisper { fn filter_segments(segments: Vec) -> Vec { segments .into_iter() - .filter(|s| { - let t = s.text.trim().to_lowercase(); - - !(s.confidence < 0.005 - || t == "you" - || t == "thank you" - || t == "you." - || t == "thank you." - || t == "♪") - }) + .filter(|s| !Self::is_hallucination(s)) .collect() } + fn is_hallucination(s: &Segment) -> bool { + if s.confidence < 0.005 { + return true; + } + + let t = s.text.trim().to_lowercase(); + let stripped = t.trim_matches(|c: char| c.is_ascii_punctuation()); + + if matches!( + stripped, + "" | "you" + | "the" + | "thanks" + | "thank you" + | "bye" + | "goodbye" + | "bye bye" + | "so" + | "oh" + | "uh" + | "hmm" + | "ah" + | "music" + ) { + return true; + } + + if t.contains('♪') || t.contains('🎵') { + return true; + } + + stripped.starts_with("thank you") + || stripped.starts_with("thanks for watching") + || stripped.starts_with("thanks for listening") + || stripped.starts_with("please subscribe") + || stripped.starts_with("like and subscribe") + || stripped.starts_with("subtitles by") + || stripped.starts_with("subscribe to") + } + unsafe fn suppress_beg(params: &mut FullParams, token_beg: &WhisperTokenId) { unsafe extern "C" fn logits_filter_callback( _ctx: *mut whisper_rs::whisper_rs_sys::whisper_context,