Pace Talk audio over gateway relay
This commit is contained in:
@@ -243,7 +243,14 @@ class AthenaTalkBridge {
|
||||
if (generation !== this.generation || !this.isConnected()) return;
|
||||
const frameBytes = 24000 * 2 / 50;
|
||||
for (let offset = 0; offset < pcm.length; offset += frameBytes) {
|
||||
if (controller.signal.aborted || generation !== this.generation || !this.isConnected()) {
|
||||
return;
|
||||
}
|
||||
this.req.onAudio?.(pcm.subarray(offset, Math.min(offset + frameBytes, pcm.length)));
|
||||
// Gateway relay drops audio frames when its WebSocket queue is full.
|
||||
// Pace 20 ms PCM frames in realtime instead of flooding the complete
|
||||
// synthesized response into the socket in a few milliseconds.
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
}
|
||||
this.req.onResponseDone?.({ status: "completed", responseId });
|
||||
this.req.onEvent?.({ direction: "server", type: "response.done", responseId });
|
||||
|
||||
Reference in New Issue
Block a user