Overview
Streaming TTS starts playing audio before the entire synthesis is complete. This is particularly useful for:- Long text passages
- Voice assistants responding in real-time
- Reducing perceived latency
synthesizeStream
synthesizeStream yields TTSOutput chunks as the backend produces them. Each chunk
carries its own audioData, chunkIndex, and isFinal flag.
synthesizeStream(String text, {TTSOptions? options}), with options
named rather than positional.
Failure contract
The stream never throws. An uninitialized SDK, a failed phase-2 readiness check, or no loaded voice finishes the stream silently with no chunks. A session-start failure arrives as one terminalTTSOutput with isFinal true and a non-empty errorMessage prefixed
TTS stream failed:.
Chunked Synthesis
If you want sentence-level boundaries rather than backend chunks, split the text yourself and callspeak per sentence. speak synthesizes and plays through the SDK’s playback
manager, so each call blocks until its audio is queued.
With Voice Agent Pipeline
The voice agent runs synthesis and playback for each turn itself. Load the three models, initialize the agent, and consume events.Latency Optimization Tips
Preload Voice Model
Preload Voice Model
Load the TTS voice during app startup or idle time, not when the user first needs it.
Use Faster Voices
Use Faster Voices
Smaller voice models synthesize faster. Choose based on your quality/speed tradeoff.
Sentence-Level Streaming
Sentence-Level Streaming
For very long responses, synthesize and play sentence by sentence rather than waiting for the
complete response.
Buffer Management
Buffer Management
Start playback as soon as you have enough audio buffered (typically 100-200ms).
See Also
synthesize()
Basic synthesis
Voice Agent
Complete voice pipeline