mirror of
https://github.com/block/buzz.git
synced 2026-11-01 15:01:12 +00:00
fix(desktop): cancel streamed speech on PTT
Signed-off-by: John Tennant <jtennant@squareup.com>
This commit is contained in:
@@ -932,7 +932,7 @@ fn release_tts_active_if_drained(player_empty: bool, tts_active: &AtomicBool) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn is_tts_interruptible(tts_active: &AtomicBool, tts_synthesizing: &AtomicBool) -> bool {
|
||||
pub(crate) fn is_tts_interruptible(tts_active: &AtomicBool, tts_synthesizing: &AtomicBool) -> bool {
|
||||
tts_active.load(Ordering::Acquire) || tts_synthesizing.load(Ordering::Acquire)
|
||||
}
|
||||
|
||||
|
||||
@@ -300,9 +300,14 @@ pub fn run() {
|
||||
if let Ok(hs) = state.huddle_state.lock() {
|
||||
hs.ptt_active
|
||||
.store(true, std::sync::atomic::Ordering::Release);
|
||||
// Only cancel TTS if it's actually playing — avoids
|
||||
// a stale cancel flag that drops the next queued message.
|
||||
if hs.tts_active.load(std::sync::atomic::Ordering::Acquire) {
|
||||
// Cancel queued playback and in-flight synthesis.
|
||||
// The synthesizing flag keeps barge-in armed during
|
||||
// silent decoder gaps without leaving a stale cancel
|
||||
// flag after the utterance finishes.
|
||||
if huddle::tts::is_tts_interruptible(
|
||||
hs.tts_active.as_ref(),
|
||||
hs.tts_synthesizing.as_ref(),
|
||||
) {
|
||||
hs.tts_cancel
|
||||
.store(true, std::sync::atomic::Ordering::Release);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user