synthesizeStream yields audio in chunks so playback can start before the whole passage is rendered.
Basic usage
Method signature
async nor throws: it returns immediately. Each element is a full
RATTSOutput carrying one chunk of audio, not a bare Data. There is no onAudioChunk callback.
The stream finishes without yielding anything when the SDK is not initialized or no model is loaded
under .speechSynthesis.
Chunk shape
Every element is anRATTSOutput. The fields that matter while streaming:
Streaming audio player
RATTSOptions.defaults() sets audioFormat = .pcm and sampleRate = 22050. Prepare the player with
the sampleRate reported on the first chunk rather than assuming a value.
SwiftUI integration
Sentence by sentence
When you want a real pause between sentences, synthesize each one and wait out its duration.speak returns after playback finishes, so no manual sleep is needed.
Buffering
Scheduling every chunk the instant it arrives can stutter on slow devices. Hold a few back first.Use cases
Long-form reading
Long-form reading
Speaking an LLM response
Speaking an LLM response
Accumulate tokens and hand each completed sentence to the synthesizer.For a full conversational loop, the voice agent already wires
VAD, STT, LLM, and TTS together.
Reading UI content aloud
Reading UI content aloud
Stopping
Task that consumes the stream also tears down the native session, because the
stream’s termination handler cancels the underlying work.
Error handling
There is nothing to catch. Failures arrive as a chunk with a non-emptyerrorMessage.
Performance tips
synthesize()
Non-streaming synthesis
Voices
Voice selection