feat: improve meeting mode trigger to detect speech as fallback
Meeting mode auto-start now triggers on system audio energy OR speech detection (VAD). Fixes issue where Electron-based apps like Nextcloud Talk were not triggering recording because ScreenCaptureKit didn't capture their audio reliably. Also improved debug logging. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -242,26 +242,33 @@ impl AudioProcessor {
|
|||||||
// Threshold 0.01 is roughly -40dB, should cover ringtones/speech easily but ignore silence/hiss.
|
// Threshold 0.01 is roughly -40dB, should cover ringtones/speech easily but ignore silence/hiss.
|
||||||
|
|
||||||
let system_active = max_system_energy > 0.005;
|
let system_active = max_system_energy > 0.005;
|
||||||
|
|
||||||
// Periodically log energy to help debug why meeting mode might not start
|
// Periodically log energy to help debug why meeting mode might not start
|
||||||
if self.last_event_time.elapsed().as_millis() > 2000 && self.recording_mode == "meeting" {
|
if self.last_event_time.elapsed().as_millis() > 2000 && self.recording_mode == "meeting" {
|
||||||
if let Some(app) = &self.app_handle {
|
if let Some(app) = &self.app_handle {
|
||||||
emit_log(app, "DEBUG", &format!("Waiting for Meeting... Current System Energy: {:.4} (Threshold: 0.005)", max_system_energy));
|
emit_log(app, "DEBUG", &format!(
|
||||||
|
"Waiting for Meeting... SysEnergy: {:.4} (thr: 0.005), VAD Speech: {} | SysQueue empty: {}",
|
||||||
|
max_system_energy, self.is_speech_active,
|
||||||
|
if let Ok(q) = self.system_queue.lock() { q.is_empty() } else { true }
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODE-SPECIFIC TRIGGER LOGIC:
|
// MODE-SPECIFIC TRIGGER LOGIC:
|
||||||
// "voice" -> Trigger if user speaks (is_speech_active)
|
// "voice" -> Trigger if user speaks (VAD)
|
||||||
// "meeting" -> Trigger ONLY if system audio energy detected (Call starting)
|
// "meeting" -> Trigger if system audio energy detected OR speech detected.
|
||||||
|
// Some apps (e.g. Electron-based Nextcloud Talk) may route audio
|
||||||
|
// in ways that ScreenCaptureKit doesn't always capture immediately.
|
||||||
|
// Allowing speech as a fallback trigger ensures calls are recorded.
|
||||||
let trigger = if self.recording_mode == "voice" {
|
let trigger = if self.recording_mode == "voice" {
|
||||||
self.is_speech_active
|
self.is_speech_active
|
||||||
} else {
|
} else {
|
||||||
system_active
|
system_active || self.is_speech_active
|
||||||
};
|
};
|
||||||
|
|
||||||
if trigger {
|
if trigger {
|
||||||
// Trigger Detected!
|
// Trigger Detected!
|
||||||
println!("Auto-Start: Call detected (SysEnergy: {}). Flushing pre-roll...", max_system_energy);
|
println!("Auto-Start: Call detected (SysEnergy: {}, Speech: {}). Flushing pre-roll...", 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