Get started with Faseeh’s Text-to-Speech API in three simple steps.
Prerequisites
- An API key from the Faseeh dashboard
- A model ID (retrieved from
/models endpoint)
- A voice ID for text-to-speech generation
Step 1: Get Your API Key
Create an API key in the Faseeh dashboard. You’ll use this key to authenticate all API requests.
Keep your API key secure and never expose it in client-side code or public repositories.
Step 2: Retrieve Available Models
First, get a list of available models:
curl -X GET "https://api.faseeh.ai/api/v1/models" \
-H "x-api-key: YOUR_API_KEY"
Response:
[
{
"id": "uuid",
"model_id": "model_123",
"model_name": "Faseeh Arabic v1",
"cost": 0.0001,
"description": "High-quality Arabic voice synthesis"
}
]
Step 3: Generate Speech
Option A: Streaming Audio Output
Generate speech with streaming PCM16 audio:
curl -X POST "https://api.faseeh.ai/api/v1/text-to-speech/MODEL_ID" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"voice_id": "VOICE_ID",
"text": "مرحبا بك في فصيح كيف يمكنني مساعدتك اليوم",
"stability": 0.5,
"streaming": true
}' \
--output audio.pcm
Option B: Complete Audio File (WAV)
Generate speech and receive a complete WAV file:
curl -X POST "https://api.faseeh.ai/api/v1/text-to-speech/MODEL_ID" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"voice_id": "VOICE_ID",
"text": "مرحبا بك في فصيح كيف يمكنني مساعدتك اليوم",
"stability": 0.5,
"streaming": false
}' \
--output audio.wav
Option C: WebSocket Streaming
For real-time streaming, use WebSocket:
const ws = new WebSocket('wss://api.faseeh.com/api/v1/text-to-speech?x-api-key=YOUR_API_KEY');
ws.onopen = () => {
// Initialize connection
ws.send(JSON.stringify({
type: 'initConnection',
model_id: 'MODEL_ID',
voice_id: 'VOICE_ID',
voice_settings: {
stability: 0.5
}
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'connectionInitialized') {
// Send text for generation
ws.send(JSON.stringify({
type: 'text',
text: 'مرحبا بك في فصيح كيف يمكنني مساعدتك اليوم',
try_trigger_generation: true
}));
} else if (data.audio) {
// Handle audio chunks (base64 encoded)
const audioData = atob(data.audio);
// Process audio chunk
}
};
Next Steps