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:
parent
07d02a51fb
commit
4216502868
2 changed files with 7 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue