Text to speech
Uzbek text becomes an audio file: send the text, get the recording back. Text to speech is in beta and open to every account.
Coming soon
- A streaming model. Audio arrives in pieces without waiting for the whole text: for voice agents and live calls.
- Many new live voices.
Voices
voice | Voice |
|---|---|
zebo | Zebo, female voice (the default) |
doston | Doston, male voice |
GET /v1/tts/voices returns this list with an available field: a voice is available when at least one server serves it right now.
Role and style
Both voices speak in one of their roles and one of that role's styles. The default is role operator, style neutral.
role | Styles (style) |
|---|---|
operator — a call-centre operator | neutral, warm, cheerful, calm, empathetic |
assistant — a voice assistant | neutral, warm, cheerful, calm, empathetic |
Each voice's roles and styles come in GET /v1/tts/voices in the roles field; a role's first style is its default. The price does not depend on the style.
POST /v1/tts: speak a text
The same project token as for transcription. The body is JSON:
| Field | What it is |
|---|---|
text | The text, up to 4,000 characters. Latin or Cyrillic script; numbers, dates, phone numbers and web addresses are read as words |
voice | zebo or doston, zebo by default |
role | operator (the default) or assistant |
style | A style of the role: neutral (the default), warm, cheerful, calm, empathetic |
format | mp3, wav (the default) or ogg (Opus) |
sample_rate | The file's rate, 8000–48000 Hz; by default the voice's own, 22050 Hz |
dialect | Conversational pronunciation, as in everyday Tashkent speech: "hozir" sounds like "hozi", "bo‘lib" like "bo‘p". On unless false; turn it off for formal text and news |
hesitations | true adds pauses and sounds like "Aa…" and "Eee…" where a live speaker would make them, so a call sounds less synthetic; off unless true. The cabinet's "Conversational speech" turns on this and dialect together |
no_wait | true answers at once with the job's id instead of waiting for the audio |
[pause] in the text makes a short pause and [laugh] a laugh. There are no other tags or markup. The dialect pronunciation keeps Uzbek words: it does not swap in Russian loans such as "dostavka" or "skidka".
curl -X POST https://console.gapi.uz/v1/tts \
-H "Authorization: Bearer $GAPI_TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "Assalomu alaykum! Buyurtmangiz ertaga soat 10 da yetkaziladi.", "voice": "zebo", "format": "mp3"}' \
-o salom.mp3A 200 answer is the audio file itself (audio/mpeg, audio/wav or audio/ogg) with the headers X-Job-Id, X-Voice, X-Audio-Seconds and X-Cost-G. With Accept: application/json the answer is JSON: id, voice, role, style, said (the text as the voice read it), format, sample_rate, audio_seconds and audio_b64 (the file in base64).
The request waits up to two minutes for the audio. If the text was not spoken by then, the answer is 202 with id and result_url: fetch the file from there.
GET /v1/tts/{id}: the result
A finished job's audio, in the same form as the POST /v1/tts answer; while the job is still working, JSON with state (queued, running). The audio is kept for 24 hours, then the answer is 410 result_expired.
GET /v1/tts: recent requests
The project's requests, newest first: ?limit= up to 100 (20 by default) and ?offset=. Each has id, state, voice, role, style, format, chars, cost_g, audio_seconds, created_at, finished_at, text, said, expires_at and result_url. text is the text you sent and stays in the history; said (the text as the voice read it) is there while the audio is kept.
Price
3.2 g per 1,000 characters of the text sent, spaces included. The price is known before the speech is made: it comes back in X-Cost-G (and in cost_g with no_wait), is reserved with the request and charged when the audio is ready. A request that fails costs nothing.
Errors
| Code | What it means |
|---|---|
403 tts_not_available | Text to speech is not open to this account yet |
400 tts_text_empty, 400 tts_text_too_long | The text is empty or longer than 4,000 characters |
400 tts_voice_unknown | No such voice; the hint lists them |
400 tts_role_unknown, 400 tts_style_unknown | The voice has no such role or style; the hint lists them |
400 tts_format_unsupported, 400 tts_sample_rate_unsupported | A format or rate that is not supported |
503 tts_voice_unavailable, 503 no_runner_for_tts | The voice, or every speech server, is restarting; try again in a couple of minutes |
429 insufficient_balance | The balance is less than the text costs |