openai/openai-realtime-api-beta

client.appendInputAudio not working

Opened this issue · 3 comments

Seems like server-side VAD isn't working. I'm routing audio from ReactJS client through Node.JS WebSocket and then through the RealtimeClient.

GPT never creates a response, or updates the conversation. I can't pick up on these events.

Anyone else have this problem? Did manual (not server_vad) end up working?

Nevermind, got it working
const buf = new Uint8Array(e.data).buffer;
the crucial line to convert ArrayBuffer(8192) --> ArrayBuffer that can used in client.appendInputAudio
Wish this was included in docs

Screenshot 2024-12-16 at 4 56 48 PM this worked for me

if you get audio payload as base64 you'll have to convert it to an array buffer.
this code helped me:

          // 1. Decode using built-in atob (returns a binary string)
          const binaryString = atob(base64Payload);
          const len = binaryString.length;
          // 2. Convert binary string to Uint8Array
          const bytes = new Uint8Array(len);
          const bytes = new Uint8Array(len);
          for (let i = 0; i < len; i++) {
            bytes[i] = binaryString.charCodeAt(i);
          }
          // 3. Get the underlying ArrayBuffer
          const audioBuffer: ArrayBuffer = bytes.buffer;
          client.appendInputAudio(audioBuffer);