Fix bug where disabling PTT would incorrectly stop VAD capture
All checks were successful
Build and Release / build-linux (push) Successful in 32s
Build and Release / build-windows (push) Successful in 2m20s
Build and Release / release (push) Successful in 9s

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-17 17:10:21 +01:00
parent a14d068ada
commit 0010bc6cf7

View File

@@ -706,6 +706,17 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
state := "OFF" state := "OFF"
if m.vadEnabled { if m.vadEnabled {
state = "ON" state = "ON"
// Ensure capturer is running if VAD is on
if m.audioCapturer != nil && !m.audioCapturer.IsRunning() {
if err := m.audioCapturer.Start(); err != nil {
m.addLog("Error starting VAD capture: %v", err)
}
}
} else {
// Stop if PTT is also off
if !m.isPTT && m.audioCapturer != nil && m.audioCapturer.IsRunning() {
m.audioCapturer.Stop()
}
} }
m.addLog("Voice Activation (Gate): %s", state) m.addLog("Voice Activation (Gate): %s", state)
return m, nil return m, nil
@@ -714,12 +725,15 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
// Toggle voice (PTT) // Toggle voice (PTT)
m.isPTT = !m.isPTT m.isPTT = !m.isPTT
if m.isPTT { if m.isPTT {
if m.audioCapturer != nil { if m.audioCapturer != nil && !m.audioCapturer.IsRunning() {
m.audioCapturer.Start() if err := m.audioCapturer.Start(); err != nil {
m.addLog("Audio capture error: %v", err)
}
} }
m.addLog("🎤 Transmitting...") m.addLog("🎤 Transmitting...")
} else { } else {
if m.audioCapturer != nil { // Stop only if VAD is also off
if !m.vadEnabled && m.audioCapturer != nil && m.audioCapturer.IsRunning() {
m.audioCapturer.Stop() m.audioCapturer.Stop()
} }
m.addLog("🎤 Stopped transmitting") m.addLog("🎤 Stopped transmitting")