AKG
04/02/2025, 3:53 PMVapi Support Bot
04/02/2025, 3:54 PMlistenUrl
by triggering the /call
endpoint
2. Use this URL to connect to a WebSocket and stream the audio data in real-time
3. Process the audio data as needed
Here's a JavaScript example of how to handle the incoming audio stream:
javascript
const WebSocket = require('ws');
const fs = require('fs');
let pcmBuffer = Buffer.alloc(0);
const ws = new WebSocket("wss://aws-us-west-2-production1-phone-call-websocket.vapi.ai/7420f27a-30fd-4f49-a995-5549ae7cc00d/transport");
ws.on('open', () => console.log('WebSocket connection established'));
ws.on('message', (data, isBinary) => {
if (isBinary) {
pcmBuffer = Buffer.concat([pcmBuffer, data]);
console.log(`Received PCM data, buffer size: ${pcmBuffer.length}`);
// This is where you would process the audio data
// or combine it with your screen recording stream
} else {
console.log('Received message:', JSON.parse(data.toString()));
}
});
## Audio Stream Format
According to the [Vapi documentation](https://docs.vapi.ai/documentation/advanced-concepts/customization/custom-transcriber), the audio stream is in raw stereo PCM format (16-bit) with the following specifications:
- Encoding: linear16
- Container: raw
- Sample Rate: 16000
- Channels: 2
For browser-based applications, you might want to use the AudioContext
API to process the audio:
```javascriptVapi Support Bot
04/02/2025, 3:54 PMVapi
04/06/2025, 9:19 AM