Real-time API
Connection keepalive
Learn how to keep a WebSocket connection alive during idle periods in Soniox Text-to-Speech.
Overview
In real-time Text-to-Speech, there may be periods when you are not sending any text. To keep the session alive, send a keepalive control message:
This keeps the WebSocket connection from being closed during idle periods.
When to use
Send keepalive messages whenever:
- You are not sending text for an extended period.
- You want to keep the WebSocket connection open between streams.
You can also send them on a fixed interval even while sending text.
Key points
- The keepalive message does not trigger Text-to-Speech generation and has no server-side effect other than maintaining the connection.
- Send a keepalive message every 20–30 seconds to prevent idle timeouts.