diff --git a/cmd/tui/model.go b/cmd/tui/model.go index 6a13686..4baa32a 100644 --- a/cmd/tui/model.go +++ b/cmd/tui/model.go @@ -706,6 +706,17 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { state := "OFF" if m.vadEnabled { 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) return m, nil @@ -714,12 +725,15 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { // Toggle voice (PTT) m.isPTT = !m.isPTT if m.isPTT { - if m.audioCapturer != nil { - m.audioCapturer.Start() + if m.audioCapturer != nil && !m.audioCapturer.IsRunning() { + if err := m.audioCapturer.Start(); err != nil { + m.addLog("Audio capture error: %v", err) + } } m.addLog("🎤 Transmitting...") } 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.addLog("🎤 Stopped transmitting")