Text to speech for AI voice agents: the voice layer, fast and cheap
An AI voice agent is a chain: speech recognition turns the caller’s words into text, a language model writes the answer, and text to speech says it. The last step decides how the agent sounds and much of how fast it feels, and with per-character pricing it is often the biggest bill.
The SuperClonica speech API is built for this layer. It streams audio from about 300 ms in our measurements, is priced by time rather than characters, and lets an agent speak with any of 190 catalog voices or a voice you train yourself. This guide shows how to wire it in and where its limits are.
Speak sentence by sentence
Do not wait for the model to finish its whole answer. Read its output as a stream, cut it at the end of each sentence and send every sentence to the speech API as soon as it is complete, with "stream": true. The first sentence starts playing while the model is still writing the next one.
Short sentences make the first sound come sooner. A long monologue still works: with streaming, a long text is split into pieces, voiced on several workers at once and played from the first piece.
import os, requests
URL = "https://superclonica.com/api/v1/speech"
HEADERS = {"Authorization": "Bearer " + os.environ["SUPERCLONICA_KEY"]}
def say(sentence, voice="F1", language="en"):
with requests.post(URL, headers=HEADERS, stream=True, timeout=120,
json={"text": sentence, "voice": voice, "language": language, "stream": True}) as answer:
answer.raise_for_status()
for chunk in answer.iter_content(4096):
player.write(chunk) # an Ogg player or decoder of your choiceLatency you can expect
In our measurements the first sound arrives from about 300 ms after the request, plus your network time to the server. Ogg streams at once; mp3 and wav stream when the text is longer than about half a minute of speech, so use Ogg for an agent. The API answers over plain HTTPS with chunked audio: there is no WebSocket, and each sentence is one request.
Phone calls
Telephony usually wants 8 kHz μ-law audio: Twilio Media Streams, for example, sends and receives audio/x-mulaw at 8000 Hz. Decode the Ogg stream, resample it to 8 kHz and encode it to μ-law before you send it to the call; the guide on custom voices for Twilio shows the conversion for prerecorded prompts.
How plans limit an agent
A plan gives seconds of audio in every 10-minute window: Starter, $5 a month, voices 3 minutes in each window, Author 8, Pro 20, Studio 65. That is the total speech of all your conversations together, so it sets how many calls can talk at once. An agent speaks perhaps a third of a call, so Starter fits about one busy line, Pro around five or six. When a window is used up, the API answers 429 with Retry-After; nothing is charged for a refused or failed request.
The free key gives a minute of audio a day: enough to build and test the agent before you pay.
Choosing the voice
Every catalog voice works through the API by the ID shown on its page, on any plan. Calm narrator and announcer voices suit support lines; brighter voices suit sales and games. Listen to the demos and voice the same test sentence with two or three voices on their pages first. You can also train a voice from your own recording on the site, for example the voice of your brand.
Supertonic 3 speaks 31 languages but not Chinese yet, and it has no SSML or word timestamps; if your agent needs those, a large cloud TTS is the better fit.