GUIDE

A streaming text to speech API: the first sound from 300 ms

A text to speech API that returns a finished file makes the listener wait for the whole text. For a chat bot, a game character or a long article that wait is the difference between an app that answers and one that thinks.

The SuperClonica speech API can stream instead: send "stream": true and the audio comes as it is made. In our measurements on the live service the first sound came from 300 ms after the request, and a long text did not delay it, because the text is voiced in pieces and the first one goes out first.

How streaming works here

The text is split at sentence boundaries, and the pieces are voiced on several workers at once. The first piece is small and takes priority over everything else in the queue, so it is ready soon whatever follows. The server joins the pieces into one Ogg stream in order and sends each as soon as it is there, while the rest are still being voiced.

  • First sound: from 300 ms in our measurements, measured to the first audio bytes.
  • A 3,839-character text: first sound in about half a second, the whole file in 5.6 seconds.
  • About 16,000 characters, 15.6 minutes of speech: the whole file in 25.6 seconds.
  • Timings depend on the load at the moment; under heavy load requests wait in a fair queue.

Call it

Create a key in the API section of your workspace, then send the text with "stream": true. With curl, -N turns off buffering so you can pipe the stream into a player:

curl -N https://superclonica.com/api/v1/speech -H "Authorization: Bearer $SUPERCLONICA_KEY" -H "Content-Type: application/json" -d '{"text": "Hello! This sentence plays while the next one is made.", "voice": "F1", "language": "en", "stream": true}' | ffplay -nodisp -autoexit -

In Python, requests with stream=True and iter_content gives you the bytes as they come; in a browser, point an audio element at your own endpoint that passes the stream through.

What to know before you build on it

Ogg Vorbis, the default format, streams at any length; mp3 and wav stream once the text is longer than about half a minute of speech and come as one file otherwise. If something fails before the first sound, the answer is an ordinary error with a status code; after it, the transfer ends early, so treat a stream that stops short as failed and send the text again. A 503 answer means the queue is full: wait the seconds in its Retry-After header and send again with the same Idempotency-Key.

Where other services are ahead

ElevenLabs and Cartesia also take the text itself as a stream over WebSocket, which suits voice agents that speak while a language model is still writing. The SuperClonica API takes the whole text in one request. Supertonic 3 has no Chinese yet, and big clouds offer SSML and word timings. If you need those, they are the better choice; if you need the first sound fast and many hours cheap, try ours on the free plan.