audio stream codec for the monitor": {"listenUrl":...
# support
u
I am trying to capture the liive stream and play it realtime... but cant find doc on this for the websocket audio stream
v
You can continue this conversation by mentioning me in the message.
@~Stu~ CoreAspect.Agency I'm here to help! To capture and play a live audio stream in real-time using VAPI, you would typically use the Vapi Client SDKs which handle audio streaming automatically. Since you're looking for documentation on handling the WebSocket audio stream, here's a general approach you can take: 1. **Initialize the Vapi Client SDK**: Depending on your platform (Web or iOS), you need to initialize the SDK first. This will set up the necessary configurations for audio streaming. 2. **Start a Call**: Use the SDK's interface to start a call. This will open a WebSocket connection and start streaming audio. 3. **Handle Incoming Audio**: The SDK will provide callbacks or events for incoming audio data. You can use these to process or play the audio in real-time. 4. **Send Audio**: If you want to send audio back, you can use the provided methods in the SDK to capture audio from the microphone and send it over the WebSocket connection. For specific documentation, you can visit the GitHub repositories for the Vapi Web or Vapi iOS SDKs. There you'll find detailed instructions and examples on how to implement the SDK in your application. If you need direct links to the documentation or specific guidance on using the SDKs, please let me know which platform you're working with (Web or iOS), and I can provide more detailed assistance.
c
You talking about what I told you?
u
i am digging around in this request: https://api.vapi.ai/call/phone "monitor": { "listenUrl": "wss://aws-us-west-2-production3-phone-call-websocket.vapi.ai/7e7e768a/transport", "controlUrl": "https://aws-us-west-2-production3-phone-call-websocket.vapi.ai/7e7e768a/control" } }, and I am trying to stream the websocket data, hwoever all methods to decode have failed so far.
c
Yea cuase you have to build around it. Websockets you cant just click on it.
u
yea, i understand that hence why i need to decode it The error EncodingError: Failed to execute 'decodeAudioData' on 'BaseAudioContext': Unable to decode audio data suggests that the audio data being received is in a format that cannot be decoded by the Web Audio API.
s
try this
Copy code
ts
ws.onmessage = function(event) {
  const message = event.data;
  
  if (typeof message !== 'string') {
    //message is an ArrayBuffer, which is the raw PCM audio data
    const audioBuffer = new Uint8Array(message);
    console.log('Received audio data:', audioBuffer);
    
    // You can then process or decode this audio data for playback or analysis
  }
};
s
Useful, thanks! tag colleague @Krishna
19 Views