3. Text-to-Speech (TTS)¶
Endpoint¶
POST /api/v1/tts
Content-Type: application/json
Request Parameters¶
| Parameter | Type | Description |
|---|---|---|
text |
string | Text to convert to speech (max 5000 characters) |
lang |
string | Language (uz, ru, en). Default: en |
voice |
string | Optional: Voice name (Aziza, Nargiza, Soliha, Sherzod, Aziz, Rachel, Arnold). Default: Aziza |
blocking |
boolean | true = wait for audio, false = return task ID |
webhook_url |
string | URL for POST request with result (required for non-blocking) |
Limits¶
| Limit | Value |
|---|---|
| Max text length | 5,000 characters |
| Auto-chunking threshold | 400 characters |
Notes:
- If text > 5,000 characters → error returned (
text_too_long). - Texts longer than 400 characters are automatically split into chunks (respecting sentence boundaries) and merged into a single audio file.
- Balance check: System checks if your balance is sufficient before processing.
webhook_urlis required for non-blocking tasks.
Available Voices¶
Uzbek (uz)
- Aziza (Female) [Default]
- Nargiza (Female)
- Soliha (Female)
- Sherzod (Male)
- Aziz (Male)
Russian (ru) & English (en)
- Rachel (Female)
- Arnold (Male)
Example Request¶
Default voice (Aziza):
curl -X POST "https://developer.kotib.ai/api/v1/tts" \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{
"text": "Assalomu alaykum! Bu test xabari.",
"lang": "uz",
"blocking": true
}'
Specific voice (e.g., Aziz):
curl -X POST "https://developer.kotib.ai/api/v1/tts" \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{
"text": "Salom dunyo!",
"lang": "uz",
"voice": "Aziz",
"blocking": true
}'
Example Response (blocking = false)¶
{
"status": "processing",
"id": "tts_987654321",
"message": "TTS generation scheduled. Poll /get-status or await webhook."
}
Example Response (blocking = true)¶
{
"status": "success",
"audio_url": "https://developer.kotib.ai/media/tasks/tts_123456789.mp3",
"character_count": 34,
"cost": 340
}
Pricing¶
TTS is charged per character:
- 1 character = 8 so'm
Pricing Examples
| Text Length | Cost |
|---|---|
| 100 characters | 800 so'm |
| 500 characters | 4,000 so'm |
| 1,000 characters | 8,000 so'm |
| 5,000 characters | 40,000 so'm |
Navigation¶
- ← Translation | Get Status →