fix(web): Barge-in — in-flight TTS-Chunks nach interrupt verwerfen
Beim Barge-in konnte ein Audio-Chunk, der im schmalen Fenster zwischen gesendetem interrupt und dem interrupted-Event/ws.close noch eintraf, weiter eingeplant und ~0,2-0,3 s abgespielt werden (im Browser verifiziert). Fix: Beim Senden von interrupt wird die WS als _aborted markiert; der onmessage-Binär-Handler verwirft danach eintreffende Chunks, statt sie via scheduleChunk weiter abzuspielen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5919a74cff
commit
5c3deba5ac
1 changed files with 2 additions and 1 deletions
|
|
@ -630,6 +630,7 @@ function runTurn(path, onopen) {
|
|||
|
||||
ws.onmessage = (event) => {
|
||||
if (typeof event.data !== "string") {
|
||||
if (ws._aborted) return; // nach Barge-in: in-flight-Chunks verwerfen, nicht mehr abspielen
|
||||
pcm.push(event.data); // immer cachen (Replay je Bubble)
|
||||
if (expectChunk) { // satzweiser Chunk -> sofort lueckenlos abspielen
|
||||
expectChunk = false;
|
||||
|
|
@ -792,7 +793,7 @@ micBtn.addEventListener("click", () => {
|
|||
unlockTTS(); // iOS: Geräte-TTS bei der Nutzergeste freischalten
|
||||
if (busy) {
|
||||
// Barge-in: laufende KI-Antwort sofort unterbrechen
|
||||
if (activeWs) activeWs.send(JSON.stringify({ type: "interrupt" }));
|
||||
if (activeWs) { activeWs._aborted = true; activeWs.send(JSON.stringify({ type: "interrupt" })); }
|
||||
stopAudio();
|
||||
statusEl.textContent = "Unterbrochen";
|
||||
// busy + Button-Reset erfolgen sobald die WS schliesst (-> runTurn resolve -> sendVoice/sendText)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue