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, qq). Default: en |
voice |
string | Optional: Voice name (Madina, Laylo, Malika, Dilnoza, Nilufar, Farrux, Nuriddin, Abdulloh, Bahodir, Sardor, Rustam). Default: Madina |
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¶
Pass the voice name in the voice field. Every voice works with every language (uz, ru, en, qq).
Female
- Madina [Default]
- Laylo
- Malika
- Dilnoza
- Nilufar
Male
- Farrux
- Nuriddin
- Abdulloh
- Bahodir
- Sardor
- Rustam
Example Request¶
Default voice (Madina):
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., Farrux):
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": "Farrux",
"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 →