Repository navigation
feat: send /live voice audio as binary WebSocket frames - #37
Merged
Merged
Conversation
Adds an audio-wire scenario (payload KB/s each way on the /live socket) and counts, per AudioContext, buffers that overlap or leave a short hole mid-reply. Mic frames are counted whether sent as JSON or binary, ahead of moving audio to binary frames (#24). Co-authored-by: Claude Code <noreply@anthropic.com>
A client that says binary: true in its start gets the tutor's audio as raw PCM binary frames instead of base64 inside JSON, and binary frames from any client are taken as mic audio. JSON/base64 audio still works both ways for a client that doesn't announce it (a stale cached app during rollout). Control messages stay JSON. Refs #24 Co-authored-by: Claude Code <noreply@anthropic.com>
The mic's PCM16 chunks go to the server as binary WebSocket frames and the tutor's audio comes back the same way, announced with binary: true in the start; no more base64 in the browser. About a quarter less data each way on the /live socket (browser repro: 19.7 -> 14.6 KB/s up, 28.3 -> 21.2 KB/s down). The e2e script speaks the same protocol. Bumps the shell cache version to 13. Closes #24 Co-authored-by: Claude Code <noreply@anthropic.com>
perf-server now streams mic audio the way the app does (binary frames, binary: true in the start) and reports payload KB/s both ways; --audio json measures an app from before #24. Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
…test helpers index.ts sends control messages and audio alike through one send() that calls encodeServerMessage; the harness decodes each audio event once (tagOfChunk takes a Buffer too) and builds mic frames with one helper; the repro reuses a single TextEncoder. Co-authored-by: Claude Code <noreply@anthropic.com>
The wait also matched the greeting's empty final input-text, so the test timed the wrong moment and failed now and then under a loaded full-suite run. Co-authored-by: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Voice audio on
/livenow travels as raw binary WebSocket frames in both directions, instead of being turned into base64 text inside JSON. Control messages (start, state, transcripts, reviews, errors) are still JSON. The same conversation now sends about a quarter less data each way.What changed
binary: truein itsstart.parseClientFrameandencodeServerMessageinserver/protocol.ts, and every/livemessage goes through it. The Gemini upstream still gets base64 in JSON, so the server converts once at the browser-facing edge.binary: true. The server still takes its JSON/base64 mic frames and answers it in JSON/base64. I checked this in a real browser by running the oldpublic/against the new server (below).?v=13,parley-v13,sw.js?v=13).scripts/e2e-live.mjsuses the binary protocol.scripts/perf-server.mjsstreams binary by default (--audio jsonfor an old client) and now reports bytes per second in both directions.docs/DEVELOPING.mddescribes the protocol.audio-wirescenario (/liveKB/s each way). Every scenario now checks for playback overlaps and underruns.Tests
npm testand/usr/bin/node(v20) both pass: 209 pass, 1 todo. The todo is the unrelated ACCESS_TOKENS test.test/live-client.test.js, plus new capture and player tests for the ArrayBuffer path.Measurements (before → after)
audio-wire: up / downThe full
repro-browserrun shows no other differences beyond run-to-run noise.Known issue, not changed here: when the tutor's reply is streamed in real time rather than sent in a burst, the player leaves small gaps equal to the network jitter (up to 43 ms in the fake). This is because
audio-player.jsre-applies its 120 ms look-ahead whenever less than 120 ms is queued. The real API sends replies in bursts, and in burst mode there are no gaps. The behaviour is the same before and after this change.Closes #24
🤖 Generated with Claude Code