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)
textstringRequiredWhat to say, 1 to 2,000 characters after trimming. Numbers, prices, times and phone numbers are read as Arabic words.voicestringOptionalDefault:the dialect defaultdialectstringOptionalDefault:the voice's ownArabic variety code (ps,jo,ae, ...). Alone it picks that variety's default voice; withvoicethe two must match.format"mp3" | "wav" | "pcm"OptionalDefault:mp3mp3 (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 atX-Sample-Rate).model"shihab-tts-v1"OptionalDefault:shihab-tts-v1Shihab Voice TTS V1.
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.mp3Response
200 with the audio as the body, streamed while it is generated. The headers tell you what was billed:
| Header | Meaning |
|---|---|
| X-Request-Id | The request id (req_...). Quote it to support. |
| X-Characters | Characters billed: the trimmed text length. |
| X-Cost-Usd | Cost of this request in US dollars. |
| X-Sample-Rate | Sample rate of the audio (44100). |
| X-Model, X-Voice | Model 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.
| Status | code | When |
|---|---|---|
| 400 | invalid_parameter | text missing or empty, or a bad format. |
| 400 | text_too_long | More than 2,000 characters. |
| 400 | unknown_voice | voice is not a voice id from the Voices page or GET /v1/models. |
| 400 | unsupported_dialect | An unknown dialect code. |
| 400 | invalid_parameter | voice and dialect do not match. |
| 400 | unknown_model | A model other than shihab-tts-v1. |
| 401 | invalid_api_key | Missing or wrong key. |
| 402 | insufficient_credits | Your balance does not cover the characters. |
| 403 | insufficient_scope | The key has no speak scope. |
| 429 | rate_limited / concurrency_limit | Too many speech requests per minute, or streams at once. Retry-After says when. |
| 503 | capacity_exceeded / engine_unavailable | Busy for a moment. Retry after Retry-After seconds. |
Need help? Email [email protected] or message us on WhatsApp.