# Voice Stream

WebSocket-based API for bidirectional voice streaming between the Sinch platform and customer endpoints.

This service enables real-time audio streaming for outbound calls, supporting use cases such as AI-powered voice assistants,
interactive voice applications, and custom telephony integrations.

**Key Features:**

- Bidirectional audio streaming using PCM-encoded audio frames
- Flexible audio chunk sizes (e.g., 20ms frames or larger buffered chunks)
- Stream control commands for audio buffer management and connection keep-alive
- Support for call acceptance, rejection, and busy signaling


**Audio Buffering:**
The platform buffers incoming audio and plays it out to the caller. Use the `clear` command to discard buffered audio
that has not yet been played, enabling real-time interruptions for interactive applications like chatbots. The maximum buffer
is 5MBs per call. If exceeded, older data will be discarded.

**Connection Flow:**

1. Platform initiates connection with `ConnectRequest`
2. Client responds with `answer`, `busy`, or `reject`
3. If answered, bidirectional audio streaming begins
4. Either party can send audio frames as binary WebSocket messages
5. Client can send control commands (`clear`, `heartbeat`) during the stream


**Connection Loss:**
There is no reconnection mechanism. If the WebSocket connection is lost for any reason, the call is immediately considered hung up and cannot be recovered.

**Latency:**
End-to-end audio latency is the sum of network round-trip time and platform buffering delay. Sending smaller frames (e.g. 20ms)
reduces buffering delay but increases per-frame overhead; larger frames reduce overhead at the cost of higher latency.
Audio sent to the platform is queued in the playback buffer before being played out to the caller, so a large backlog of
buffered audio will delay playback. Use the `clear` command to flush unplayed audio when low latency is required,
for example to interrupt ongoing playback in conversational applications.

## Download AsyncAPI Spec

You can download the full AsyncAPI specification here:

👉 [Download stream.yml](/docs/voice-2.0/api-reference/stream)