Streaming TTS

Sending Text

How to send text to the streaming TTS WebSocket and control synthesis flow.


Best practices

  • Send complete sentences for the best prosody and naturalness.
  • Avoid sending single words or partial phrases unless latency is critical.
  • Use the flush command to force synthesis of all buffered text immediately.
  • Use the close command to gracefully end the session.

Flush & close commands

The WebSocket accepts JSON control messages to manage the synthesis pipeline.

WebSocket commands
# Send flush to synthesize all buffered text immediately
> {"type": "flush"}
# Server acknowledges:
< [binary audio data]
< {"type": "flushed", "sequence_id": 1}

# Send close to end the session
> {"type": "close"}