feat(voice): Update voice protocol implementation for new encoding/decoding support and improved audio quality

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Claude Code 2026-04-02 21:44:54 -07:00
parent 07d02a51fb
commit 4216502868
2 changed files with 7 additions and 3 deletions

View file

@ -17,8 +17,11 @@ export function encodeUpstreamFrame(frame: AudioUpstreamFrame): ArrayBuffer {
view.setUint8(0, UPSTREAM_FRAME_TYPE);
view.setUint32(1, frame.seq, false); // big-endian
const dst = new Int16Array(buffer, UPSTREAM_HEADER_BYTES);
dst.set(frame.pcm);
// Int16Array requires 2-byte-aligned offsets; UPSTREAM_HEADER_BYTES=5 is odd.
// Copy PCM bytes via Uint8Array instead.
new Uint8Array(buffer, UPSTREAM_HEADER_BYTES).set(
new Uint8Array(frame.pcm.buffer, frame.pcm.byteOffset, frame.pcm.byteLength),
);
return buffer;
}

View file

@ -76,7 +76,8 @@ export class VoiceClient {
const socket = io(`${baseUrl}/voice`, {
query: { session_id: this.config.sessionId },
transports: ['websocket'],
// Default transports: polling first (works through HTTP proxies like Vite),
// then upgrades to WebSocket automatically.
reconnection: this.config.reconnect,
reconnectionAttempts: this.config.maxReconnectAttempts,
reconnectionDelay: this.config.reconnectDelay,