Skip to main content
POST
/
text-to-speech
/
{model_id}
Generate Text-to-Speech
curl --request POST \
  --url https://api.faseeh.ai/api/v1/text-to-speech/{model_id} \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "voice_id": "<string>",
  "text": "<string>",
  "stability": 0.5,
  "streaming": true
}
'
"<string>"
POST Generate speech from Arabic text and receive a complete WAV audio file. The entire audio is generated before being returned, ensuring complete audio quality. Generate speech from Arabic text and receive a complete WAV audio file. The entire audio is generated before being returned, ensuring complete audio quality.

Endpoint

POST /text-to-speech/:model_id

Authentication

Requires API key authentication via x-api-key header.

Path Parameters

ParameterTypeRequiredDescription
model_idstringYesThe model identifier to use for generation

Request Body

FieldTypeRequiredDescription
voice_idstringYesThe voice ID to use for synthesis
textstringYesThe Arabic text to convert to speech
stabilitynumberYesVoice stability (0.0 to 1.0). Higher values produce more consistent output
streamingbooleanYesMust be false for complete WAV file response

Example Request Body

{
  "voice_id": "voice_123",
  "text": "مرحبا بك في فصيح كيف يمكنني مساعدتك اليوم",
  "stability": 0.5,
  "streaming": false
}

Response

Status Code: 200 OK Headers:
  • Content-Type: audio/wav
  • Cache-Control: no-cache
  • Content-Length: <file_size>
Body: Complete WAV audio file

Error Responses

400 Bad Request
{
  "errorCode": "400xx",
  "errorMessage": "Model not found: invalid_model_id"
}
402 Payment Required
{
  "errorCode": "402xx",
  "errorMessage": "Insufficient wallet balance. Required: $0.05, Available: $0.02"
}

Example Usage

JavaScript

const response = await fetch('https://api.faseeh.ai/api/v1/text-to-speech/MODEL_ID', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    voice_id: 'VOICE_ID',
    text: 'مرحبا بك في فصيح كيف يمكنني مساعدتك اليوم',
    stability: 0.5,
    streaming: false,
  }),
});

const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
// Use audioUrl to play or download the audio

Python

import requests

url = "https://api.faseeh.ai/api/v1/text-to-speech/MODEL_ID"
headers = {
    "x-api-key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "voice_id": "VOICE_ID",
    "text": "مرحبا بك في فصيح كيف يمكنني مساعدتك اليوم",
    "stability": 0.5,
    "streaming": False
}

response = requests.post(url, json=data, headers=headers)

if response.status_code == 200:
    with open("output.wav", "wb") as f:
        f.write(response.content)
else:
    print(f"Error: {response.status_code} - {response.text}")

Cost Calculation

The cost is calculated based on:
  • Text length (number of characters)
  • Model cost per character
Cost is deducted from your wallet balance upon successful generation.
Wallet Balance: Ensure your wallet has sufficient balance before making requests. Check your balance in the Faseeh dashboard.

Authorizations

x-api-key
string
header
required

API key for authentication

Path Parameters

model_id
string
required

The model identifier to use for generation

Body

application/json
voice_id
string
required

The voice ID to use for synthesis

text
string
required

The Arabic text to convert to speech

stability
number
required

Voice stability (0.0 to 1.0). Higher values produce more consistent output

Required range: 0 <= x <= 1
streaming
boolean
required

If true, returns streaming PCM16 audio. If false, returns complete WAV file

Response

Audio response (streaming or complete file)

PCM16 audio stream (when streaming=true)