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"
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user