Text to Speech
Convert text into speech with a MenaVoice model and voice
curl -X POST https://api.menavoice.ai/api/tts \
-H "x-api-key: $MENAVOICE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "مرحباً بكم في مينا فويس",
"voiceId": "layla",
"quality": "flash",
"dialectId": "msa"
}'import os
import requests
response = requests.post(
"https://api.menavoice.ai/api/tts",
headers={"x-api-key": os.environ["MENAVOICE_API_KEY"]},
json={
"text": "مرحباً بكم في مينا فويس",
"voiceId": "layla",
"quality": "flash",
"dialectId": "msa",
},
timeout=120,
)
print(response.json())const response = await fetch("https://api.menavoice.ai/api/tts", {
method: "POST",
headers: {
"x-api-key": process.env.MENAVOICE_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
text: "مرحباً بكم في مينا فويس",
voiceId: "layla",
quality: "flash",
dialectId: "msa",
}),
});
console.log(await response.json());{
"audio": "SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjYwLjE2LjEwMAAAAAAAAAAA...",
"mimeType": "audio/mpeg",
"voice": "layla",
"characters": 23
}{
"error": "Text exceeds 5,000 character limit"
}{
"error": "Invalid or revoked API key"
}{
"error": "Insufficient API balance ($0.00). This request needs $0.0006 — top up in the Developer dashboard under API Billing."
}{
"error": "Too many requests"
}Generates speech from text with a studio voice or a voice from your library. Send text for a single voice, or segments for a multi-speaker dialogue. The audio comes back base64-encoded in the JSON response.
Each request costs $25 per million characters of text, taken from your API credit.
Authorizations
Your API key. See Authentication.
Body
application/jsonThe text to speak, up to 5,000 characters. Required unless you send segments.
laylaThe voice. For studio voices, an ID such as layla, noura, ahmed or khaled (see Voices); an unknown ID falls back to layla. With quality set to clone, the ID of a voice in your voice library, which is then required.
flashThe model: flash (MenaVoice 1v), pro (MenaVoice 1.5), v2 (MenaVoice 2) or clone (MenaVoice Clone). An unknown value falls back to flash. See Models Overview.
Steers the delivery toward a dialect, such as egyptian, saudi, moroccan or msa. See the list of dialects. Unknown values are ignored, and so is this field with quality: "clone".
A conversation to speak instead of text: up to 40 lines and 5,000 characters in total. Each line is spoken in its own voice, and the result is one MP3.
Response
application/jsonThe generated speech, base64-encoded.
The audio format, audio/mpeg (MP3). Use it to choose a file extension or Content-Type.
The voice that spoke: a studio voice ID, or the name of a library voice. For a dialogue, every voice that spoke, separated by commas.
The number of characters billed: the length of text, or of all dialogue lines together.
Errors
| Status | When |
|---|---|
400 | text is missing or longer than 5,000 characters, segments is invalid or has more than 40 lines, or a clone voice isn't in your library. |
401 | The API key is missing or invalid. |
402 | Your API credit can't cover the request. |
429 | More than 30 requests in a minute, or more requests at once than your concurrency allows. |
502 | The voice engine didn't return audio. Retry. |
See Errors for the exact messages.
Was this page helpful?

