Skip to main content
Early Beta — The Web SDK is in early beta. APIs may change between releases.

Overview

RunAnywhere.synthesizeStream() yields TTSOutput chunks from the lifecycle-loaded voice as they are produced, so playback can start before the whole utterance is rendered. Each chunk carries its own chunkIndex, and the last one has isFinal: true.

Signature

Options match synthesize(). If the loaded WASM build lacks the lifecycle streaming exports, the call throws SDKException.backendNotAvailable.

Basic usage

Aborting mid-stream:
RunAnywhere.stopSynthesis() is the signal-free equivalent.

Decoding chunks

Each chunk’s audioData is bytes interpreted by audioFormat. AUDIO_FORMAT_PCM is little-endian float32; AUDIO_FORMAT_PCM_S16LE is little-endian int16.

AudioPlayback

AudioPlayback from @runanywhere/web/browser wraps an AudioContext buffer source.
22050 Hz is the SDK’s TTS output rate, so most Piper voices need no resampling.

Using the Web Audio API directly

Exporting to WAV

For int16 output, RunAnywhere.pcm16ToWav() wraps the bytes in a 44-byte RIFF container.
The helper assumes mono little-endian int16 input, so request audioFormat: AudioFormat.AUDIO_FORMAT_PCM_S16LE when you plan to export.

Queueing utterances

speak() awaits playback, so a plain loop plays them in order. RunAnywhere.stopSpeaking() interrupts the current one.

Synthesize

Text-to-speech synthesis

Voices

Voice models and selection