POST /api/v1/tts
Text-to-speech for Khmer and English. Send JSON, receive an MP3 audio stream.
Authentication
Bearer token API key in the Authorization header. Keys start with ds_sk_.
Request
POST /api/v1/tts HTTP/1.1
Host: doslarb.cloud
Authorization: Bearer ds_sk_...
Content-Type: application/json
{ "text": "...", "voice": "sovann" }Voice
Choose a voice with the optional voice field: sovann (Sovann) or puthi (Puthi). Omit it to default to sovann.
Response
On success the body is raw MP3 audio. A Content-Disposition filename is forwarded when the engine supplies one, and the x-audio-duration-seconds header reports the clip length in seconds.
HTTP/1.1 200 OK
Content-Type: audio/mpeg
x-audio-duration-seconds: 3.5
<MP3 binary>Input limit
Up to 1200 characters (Unicode codepoints) per request on the free tier, or 20000 on paid plans. Longer input returns 400 text_too_long.
Error codes
| Status | Type | Description |
|---|---|---|
| 400 | invalid_request | Malformed JSON body, or missing/empty text. |
| 400 | text_too_long | Text exceeds the request character limit (1200 on free plans, 20000 on paid). |
| 400 | invalid_voice | The voice value is not a known slug. |
| 401 | unauthorized | Missing or invalid API key. |
| 429 | quota_exceeded | Monthly audio-minutes quota or per-key rate limit reached. |
| 502 | upstream_failure | The speech engine returned an invalid response. |
| 503 | service_unavailable | The speech engine is temporarily unavailable. Retry after a short delay. |
| 504 | upstream_timeout | The speech engine timed out. |
Example
bash
curl -X POST https://doslarb.cloud/api/v1/tts \
-H "Authorization: Bearer ds_sk_..." \
-H "Content-Type: application/json" \
-d '{"text": "សួស្តី ពិភពលោក នេះជាការសាកល្បងបំប្លែងអក្សរទៅជាសម្លេង។", "voice": "sovann"}' \
--output speech.mp3