fix: meeting mode triggers only on system audio, not speech
Reverts speech-based fallback trigger. Meeting mode now strictly requires system audio energy > 0.005 to trigger auto-start. The system_queue always has data (even silence) from ScreenCaptureKit, so checking queue emptiness caused false positives. Speech alone must never trigger meeting mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -256,27 +256,20 @@ impl AudioProcessor {
|
|||||||
|
|
||||||
// MODE-SPECIFIC TRIGGER LOGIC:
|
// MODE-SPECIFIC TRIGGER LOGIC:
|
||||||
// "voice" -> Trigger if user speaks (VAD)
|
// "voice" -> Trigger if user speaks (VAD)
|
||||||
// "meeting" -> Trigger ONLY if system audio energy detected.
|
// "meeting" -> Trigger ONLY on system audio energy above threshold.
|
||||||
// Speech alone is NOT enough (prevents false triggers when
|
// Speech alone NEVER triggers meeting mode to prevent
|
||||||
// user talks near the mic without being in a call).
|
// false starts when user speaks near mic without a call.
|
||||||
// However, speech + ANY system audio (even below threshold)
|
// The threshold (0.005) is low enough to catch ringtones,
|
||||||
// counts as a trigger, to catch Electron apps (e.g. Nextcloud Talk)
|
// call audio, and notification sounds from any app.
|
||||||
// that may produce low-level system audio.
|
|
||||||
let sys_queue_has_data = if let Ok(q) = self.system_queue.lock() { !q.is_empty() } else { false };
|
|
||||||
let system_has_any_audio = max_system_energy > 0.0001 || sys_queue_has_data;
|
|
||||||
|
|
||||||
let trigger = if self.recording_mode == "voice" {
|
let trigger = if self.recording_mode == "voice" {
|
||||||
self.is_speech_active
|
self.is_speech_active
|
||||||
} else {
|
} else {
|
||||||
// Primary: system audio above threshold
|
system_active
|
||||||
// Fallback: speech detected AND system audio stream has ANY data
|
|
||||||
// (catches low-volume call audio from Electron/WebRTC apps)
|
|
||||||
system_active || (self.is_speech_active && system_has_any_audio)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if trigger {
|
if trigger {
|
||||||
// Trigger Detected!
|
// Trigger Detected!
|
||||||
println!("Auto-Start: Call detected (SysEnergy: {}, Speech: {}, SysHasData: {}). Flushing pre-roll...", max_system_energy, self.is_speech_active, system_has_any_audio);
|
println!("Auto-Start: Trigger! (Mode: {}, SysEnergy: {:.4}, Speech: {})", self.recording_mode, max_system_energy, self.is_speech_active);
|
||||||
self.waiting_for_speech = false;
|
self.waiting_for_speech = false;
|
||||||
|
|
||||||
// Flush Ring Buffer (Orderly: from ring_pos to end, then 0 to ring_pos)
|
// Flush Ring Buffer (Orderly: from ring_pos to end, then 0 to ring_pos)
|
||||||
|
|||||||
Reference in New Issue
Block a user