VoiceWake: add level meter

This commit is contained in:
Peter Steinberger
2025-12-08 22:28:49 +01:00
parent 6c91304400
commit 92d015333a
2 changed files with 42 additions and 0 deletions

View File

@@ -294,6 +294,7 @@ actor VoiceWakeRuntime {
self.triggerChimePlayed = false
await MainActor.run { AppStateStore.shared.stopVoiceEars() }
await MainActor.run { VoiceWakeOverlayController.shared.updateLevel(0) }
let forwardConfig = await MainActor.run { AppStateStore.shared.voiceWakeForwardConfig }
// Auto-send should fire as soon as the silence threshold is satisfied (2s after speech, 5s after trigger-only).
@@ -330,6 +331,11 @@ actor VoiceWakeRuntime {
if rms >= threshold {
self.lastHeard = Date()
}
let clamped = min(1.0, max(0.0, rms / max(self.minSpeechRMS, threshold)))
Task { @MainActor in
VoiceWakeOverlayController.shared.updateLevel(clamped)
}
}
private static func rmsLevel(buffer: AVAudioPCMBuffer) -> Double? {