Streaming TTS
Connection Lifecycle
Understand the three phases of a streaming TTS WebSocket session.
Lifecycle phases
| Phase | SDK Call | Description |
|---|---|---|
| Connect | client.tts.stream() | Opens a WebSocket connection and sends the text with config. |
| Receive | async for audio in stream | Yields binary audio chunks as they arrive from the server. |
| Done | StopAsyncIteration | The server signals completion and the async generator exits. |
Details
- The SDK manages the WebSocket connection automatically inside
AsyncShunyaClient. - Audio chunks are yielded as raw
bytesin the format specified byresponse_format. - If the connection drops unexpectedly, the SDK raises a
ConnectionError.