Fix bug where disabling PTT would incorrectly stop VAD capture
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user