streaming text-to-speech

Streaming text-to-speech that plays as it generates, in the browser or over the phone.

  • POST /v1/audio/stream, chunked HTTP
  • Up to 20,000 characters per request
  • mp3, ogg, aac, pcm, u-law formats
  • Sub-300ms first byte with Simba 3.2

definition

Streaming text-to-speech returns audio in chunks as it is generated, over a single HTTP connection. Your app decodes and plays the bytes as they arrive, so the listener hears the first sound almost immediately instead of waiting for the whole clip to render.

how-streaming-works

You call POST /v1/audio/stream. The response is chunked HTTP: audio bytes flow back continuously. Your client reads the stream, decodes each chunk, and feeds it to the audio output. First byte lands in under 300ms with Simba 3.2, and playback continues as generation continues.

audio-formats

Five formats: mp3 for general playback, ogg and aac for compressed delivery, pcm at 24kHz mono for raw audio, and u-law for telephony systems. Pick with the Accept header. WAV is not a streaming format; use the batch speech endpoint when you need a WAV file.

browser-playback

In the browser, read the response stream and feed chunks to the Web Audio API for gapless playback. Buffer a little to smooth network jitter, but not so much that you add latency. The tradeoff is buffer size against responsiveness.

telephony

For phone systems, stream u-law at 8kHz, the format telephony expects. Paired with SIP or a voice agent, streaming TTS puts generated speech straight onto a call with minimal delay.

code-samples

curl -X POST https://api.speechify.ai/v1/audio/stream \
  -H "Authorization: Bearer $SPEECHIFY_API_KEY" \
  -H "Accept: audio/mpeg" \
  -H "Content-Type: application/json" \
  -d '{"input": "Playing as it streams.", "voice_id": "george", "model": "simba-3.2"}' \
  --output speech.mp3
FAQ

Frequently asked questions

What is streaming text-to-speech?
Streaming text-to-speech sends audio back in chunks over a single HTTP connection as it is generated, instead of returning one finished file. Your app decodes and plays the bytes as they arrive, so the first sound reaches the listener in under 300ms rather than after the whole clip renders.
Which formats does streaming support?
mp3 (audio/mpeg), ogg, aac, pcm at 24kHz mono, and u-law for telephony. WAV is not available on streaming; use the batch speech endpoint for WAV. You choose the format with the Accept header.
How much text can I stream per request?
Up to 20,000 characters per request on the streaming endpoint. For longer content, chunk the text and stream the pieces in sequence to keep playback continuous.

Start building

Streaming text-to-speech that plays as it generates, in the browser or over the phone.