Text to speech
Text to speech
Turn Arabic text into natural speech in 20 Arabic varieties with Shihab Voice TTS V1, streamed while it is generated.
What Shihab Voice TTS does
Shihab Voice TTS turns Arabic text into natural speech in 20 Arabic varieties, from Palestinian, Jordanian and Lebanese to Gulf, Egyptian, Iraqi and Moroccan, plus Modern Standard Arabic. Every request is served by our in-house model Shihab Voice TTS V1 (shihab-tts-v1) in one of 88 voices: female and male voices for every variety, with Leen (ps-female, the default) and Tamer (ps-male) for Palestinian. The audio streams back while it is generated, with the first audio in about 0.2 seconds, so a voice agent or a phone line can start speaking at once. It uses the same API keys, console, balance and free credit as Shihab Voice.
Make your first audio
Send the text as JSON to POST /v1/speak and save the answer. The key needs the speak scope (new keys have every scope).
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.mp3Play it while it streams
Ask for format: "pcm" to get raw 16-bit little-endian mono samples at the rate in X-Sample-Rate (44,100 Hz), chunk by chunk as they are generated. Start playing after a few hundred milliseconds of audio and it never stutters: the voice is generated faster than real time. Long texts are spoken sentence by sentence in one continuous stream.
# Raw 16-bit PCM chunks as they are generated: play or forward them right away.
with client.speak_stream("طلبك صار جاهز، وبيوصلك خلال ربع ساعة.", voice="ps-male", format="pcm") as speech:
print(speech.sample_rate) # 44100, mono, little-endian
for chunk in speech:
speaker.write(chunk)How text is read
- Write Arabic the way you want it said, in Palestinian or standard spelling. English words mixed into Arabic are fine. Tashkeel is optional and helps with rare words.
- Numbers are read as Palestinian words: prices (
73 شيكل,$12.50), percentages (15%), times (10:30becomes عشرة ونص), ranges (10-20) and quantities. Phone numbers and codes (a leading 0 or +, or 7 digits and more) are read digit by digit. - Symbols such as
&,+and=are read as words; emoji and markdown marks are skipped. - Up to 2,000 characters per request, after trimming. Send longer scripts in several requests.
Audio formats
| format | Content-Type | What you get |
|---|---|---|
| mp3 | audio/mpeg | 44.1 kHz mono, 128 kbit/s. The default; plays everywhere. |
| wav | audio/wav | 16-bit mono, 44.1 kHz. Streamed, so the header carries no length. |
| pcm | audio/pcm | Raw 16-bit little-endian mono at X-Sample-Rate (44,100). |
Pricing and limits
$0.03 per 1,000 characters of input text (Scale $0.0225), counted after trimming. A request is billed once its audio starts streaming; a request that fails before that is free. The $5 free credit covers text to speech too. Pay as you go: 60 speech requests per minute and 1 speech stream at a time; Scale: 120 per minute and 2 at a time. See Pricing and billing and Rate limits.
Next steps
Need help? Email [email protected] or message us on WhatsApp.