Skip to content

API reference

Speak text

POST /v1/speak: text to speech, streamed.

POST /v1/speak

POSThttps://api.shihab.co.uk/v1/speak

Turn Arabic text into speech in 20 Arabic varieties. The audio streams back while it is generated. Scope: speak.

Request body (JSON)

  • textstringRequired
    What to say, 1 to 2,000 characters after trimming. Numbers, prices, times and phone numbers are read as Arabic words.
  • voicestringOptionalDefault: the dialect default
    A voice id from Voices, e.g. ps-female, jo-f3, ae-m4.
  • dialectstringOptionalDefault: the voice's own
    Arabic variety code (ps, jo, ae, ...). Alone it picks that variety's default voice; with voice the two must match.
  • format"mp3" | "wav" | "pcm"OptionalDefault: mp3
    mp3 (44.1 kHz mono, 128 kbit/s), wav (16-bit, streamed with no length in the header) or pcm (raw 16-bit little-endian mono at X-Sample-Rate).
  • model"shihab-tts-v1"OptionalDefault: shihab-tts-v1
    Shihab Voice TTS V1.
Field
curl https://api.shihab.co.uk/v1/speak \
  -H "Authorization: Bearer $SHIHAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "أهلا وسهلا، معك شهاب. كيف بقدر أساعدك اليوم؟", "voice": "ps-female", "dialect": "ps", "format": "mp3"}' \
  -o hello.mp3

Response

200 with the audio as the body, streamed while it is generated. The headers tell you what was billed:

HeaderMeaning
X-Request-IdThe request id (req_...). Quote it to support.
X-CharactersCharacters billed: the trimmed text length.
X-Cost-UsdCost of this request in US dollars.
X-Sample-RateSample rate of the audio (44100).
X-Model, X-VoiceModel and voice used.
200 OK
HTTP/1.1 200 OK
Content-Type: audio/mpeg
X-Request-Id: req_01JAB3C4D5E6F7G8H9J0K1M2N3
X-Characters: 44
X-Cost-Usd: 0.00132
X-Sample-Rate: 44100
X-Model: shihab-tts-v1
X-Voice: ps-female
Transfer-Encoding: chunked

<the mp3, streamed while it is generated>

Errors

Errors come before any audio, in the usual error format. A request that fails is not billed.

StatuscodeWhen
400invalid_parametertext missing or empty, or a bad format.
400text_too_longMore than 2,000 characters.
400unknown_voicevoice is not a voice id from the Voices page or GET /v1/models.
400unsupported_dialectAn unknown dialect code.
400invalid_parametervoice and dialect do not match.
400unknown_modelA model other than shihab-tts-v1.
401invalid_api_keyMissing or wrong key.
402insufficient_creditsYour balance does not cover the characters.
403insufficient_scopeThe key has no speak scope.
429rate_limited / concurrency_limitToo many speech requests per minute, or streams at once. Retry-After says when.
503capacity_exceeded / engine_unavailableBusy for a moment. Retry after Retry-After seconds.

Need help? Email [email protected] or message us on WhatsApp.