The Web SDK’s TTS produces raw PCM audio as Float32Array. This page covers how to work with the audio output, including playback, conversion, and integration with Web Audio API.
The Web SDK currently produces audio all-at-once (non-streaming). Streaming TTS output is planned
for a future release.
The SDK includes a built-in AudioPlayback class for playing synthesized audio:
import { TTS, AudioPlayback } from '@runanywhere/web'const result = await TTS.synthesize('Hello from RunAnywhere!')const player = new AudioPlayback()player.onComplete(() => console.log('Playback finished'))await player.play(result.audioData, result.sampleRate)
async function speakSequence(texts: string[]) { const player = new AudioPlayback() for (const text of texts) { const result = await TTS.synthesize(text) await player.play(result.audioData, result.sampleRate) }}await speakSequence(['First sentence.', 'Second sentence.', 'And the third.'])