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

StatusTypeDescription
400invalid_requestMalformed JSON body, or missing/empty text.
400text_too_longText exceeds the request character limit (1200 on free plans, 20000 on paid).
400invalid_voiceThe voice value is not a known slug.
401unauthorizedMissing or invalid API key.
429quota_exceededMonthly audio-minutes quota or per-key rate limit reached.
502upstream_failureThe speech engine returned an invalid response.
503service_unavailableThe speech engine is temporarily unavailable. Retry after a short delay.
504upstream_timeoutThe 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