AdeB
04/09/2025, 3:56 PMVapi Support Bot
04/09/2025, 3:59 PMsmartEndpointingEnabled
to false
and Deepgram's endpointing to 300ms
- Adjust the waitSecond
parameter or use custom endpointing
- Update these settings using the UPDATE /assistant/:id API
## Recording Audio Using WebSockets
If you want to record audio on your side, you can set up a WebSocket bridge between Twilio and Vapi:
```ts
app.post('/twilio/voice', async (req, res) => {
// Create a Vapi call with bypass enabled
const vapiCall = await fetch('https://api.vapi.ai/call', {
method: 'POST',
body: JSON.stringify({
phoneCallProviderBypassEnabled: true,
// other call parameters...
})
});
const { callId } = await vapiCall.json();Vapi Support Bot
04/09/2025, 3:59 PMwss://your-server.com/twilio-bridge/${callId}
});
res.type('text/xml');
res.send(twiml.toString());
});
Then handle the audio data:
```ts
twilioWs.on('message', async (data) => {
try {
const message = JSON.parse(data.toString());
if (message.event === 'media') {
const audio = Buffer.from(message.media.payload, 'base64');
// Here you can save the audio buffer to a file or storage
if (vapiTransport.readyState === WebSocket.OPEN) {
vapiTransport.send(audio);
}
}
} catch (error) {
console.error('Error processing Twilio message:', error);
}
});
Is there a specific aspect of recording or reducing the delay that you'd like me to elaborate on?
Sources:
- [Getting Started Guide](https://docs.vapi.ai/calls/call-features)
- [WebSocket Bridge Documentation](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341810370700120064)
- [Real-time Audio Recording](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333380326294290486)
- [Optimizing Network and Server Performance](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1336685825227755591)
- [Adjusting Endpointing and Transcription Settings](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1332286268805087272)Mistermanu#000
04/09/2025, 5:05 PMMistermanu#000
04/10/2025, 3:15 AMReceived PCM data, buffer size: ${pcmBuffer.length}
);
} else {
console.log('Received message:', JSON.parse(data.toString()));
}
});
ws.on('close', () => {
if (pcmBuffer.length > 0) {
fs.writeFileSync('audio.pcm', pcmBuffer);
console.log('Audio data saved to audio.pcm');
}
});
ws.on('error', (error) => console.error('WebSocket error:', error));Kings Big
04/11/2025, 7:34 AMAdeB
04/11/2025, 2:07 PMKings Big
04/11/2025, 10:00 PM