Voice AI

WebSocket Audio Streaming for Voice Bots: How It Works (2026)

How to stream live phone call audio to your own voice bot over a WebSocket: the connection lifecycle, raw L16 PCM frames, barge-in, DTMF, sample rates, and how it compares with base64 mu-law streams.

Edesy Team5 min read

Frequently asked questions

What is WebSocket audio streaming for a phone call?

The voice platform opens a WebSocket to your server when a call connects and sends the caller's audio in real time. Your server sends audio back, which the caller hears. It lets you run your own speech recognition, LLM and text-to-speech on a real phone call.

What audio format does Edesy stream?

Raw L16 PCM: signed 16-bit little-endian, mono, at 8 kHz or 16 kHz, sent as binary WebSocket frames in both directions. It is not base64 and not mu-law.

Should I use 8 kHz or 16 kHz?

Use 16 kHz if your STT and TTS work at 16 kHz, so you avoid an extra resample. Use 8 kHz if your pipeline is built for narrowband telephony audio. The rate on the number or call must match what your bot expects.

How do I handle the caller interrupting the bot?

When your voice activity detection hears the caller while the bot is speaking, send a text frame {"type":"killAudio"}. Edesy flushes the audio still queued for playback, and the caller stops hearing the old reply.

How do I end the call from the bot?

Send {"type":"disconnect"} as a text frame. You can also hang up through the REST API with DELETE /v1/calls/:sid.

When should I use Conversation Relay instead?

When you don't want to run STT and TTS yourself. Conversation Relay sends your bot text and speaks the text you send back. Media Streams gives you raw audio and full control of the pipeline.

Edesy Team

The Edesy engineering team, building voice AI, messaging, and automation products for Indian businesses.

Published

Share

Voice AIVoice APIWebSocketDevelopersTelephonyIndia
Back to blog