Basic Usage
There are two entry points.speak synthesizes and plays through the device speakers;
synthesize returns the audio and leaves playback to you.
speak returns a TTSSpeakResult; synthesize returns a TTSOutput. Both take
TTSOptions as a second positional argument.
TTSOutput
TTSSpeakResult carries the same metadata minus audioData: audioFormat, sampleRate,
durationMs, audioSizeBytes, metadata, and timestampMs.
TTSOptions
Unset fields are filled from the proto defaults before the request goes native.enableSsml is true the SDK routes your string into the request’s ssml field
instead of text.
Setup
1. Register ONNX Backend
2. Register the voice
Piper voices ship as tarballs, so they register throughregisterArchiveModel:
3. Download & Load
Playing Audio
RunAnywhere.speak(text) already does this. It synthesizes, converts the Float32 PCM to
WAV through the commons audio utility, and plays it through the SDK’s own playback
manager. You do not need to build a WAV header yourself.
RunAnywhere.tts.isSpeaking is true while a speak() call is in flight.
RunAnywhere.stopSynthesis() stops only the synthesis, leaving any playing audio alone.
Use synthesize when you need the bytes for something else, such as writing a file or
feeding your own player. output.audioData is raw PCM in output.audioFormat, not a
playable container, so wrap it before handing it to audioplayers or AVPlayer.
Complete Example
See Also
Streaming TTS
Stream audio as it’s generated
Available Voices
Browse voice options