fix: read aloud no longer stops after the first sentence when speech is slow (#32484)

speak() synthesizes one sentence at a time and enqueues each clip as it
arrives. When a clip finishes before the next one is ready, the audio queue
reports 'empty-queue', and the onStopped handler set speaking to false. The
loop only enqueues while speaking is true, so every later clip was
synthesized and then dropped, and the speaker button went back to idle.

Ignore 'empty-queue' while the synthesis loop is still running; playback
resumes on the next enqueue, and the queue's 'empty-queue' after the last
clip still ends playback as before.
This commit is contained in:
G30 2026-10-15 19:02:28 -04:00 • committed by GitHub
parent ae6793dd4f
commit 7da8653e71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -292,7 +292,10 @@
} else {
$audioQueue.setId(`${message.id}`);
$audioQueue.setPlaybackRate($settings.audio?.tts?.playbackRate ?? 1);
let synthesizing = true;
$audioQueue.onStopped = ({ event }) => {
if (event === 'empty-queue' && synthesizing) return;
speaking = false;
speakingIdx = undefined;
@ -371,6 +374,8 @@
}
}
}
synthesizing = false;
}
};