Documentation Index
Fetch the complete documentation index at: https://docs.faseeh.ai/llms.txt
Use this file to discover all available pages before exploring further.
Authentication
Requires API key authentication via x-api-key header.
Request
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|
text | string | Yes | Text to generate preview with (minimum 3 words, 10 characters) |
similarity | number | Yes | Voice similarity to source (0.0 to 1.0). Higher values produce more similar voice |
model_id | string | Yes | The model identifier to use for generation |
speed | number | No | Speech speed (0.7 to 1.2, default 1.0). Values below 1.0 slow down speech, above 1.0 speed it up |
file | File | Yes | Audio file containing the voice to preview |
Notes
- The API will process the provided audio file to generate the voice preview
text must be at least 3 words and 10 characters long
Response
Status Code: 200 OK
Headers:
Content-Type: audio/raw;codec=pcm16;rate=24000;channels=1
Cache-Control: no-cache
Connection: keep-alive
Body: Streaming PCM16 audio (24000 Hz, Mono, 16-bit)
Error Responses
400 Bad Request
{
"errorCode": "400xx",
"errorMessage": "text is required"
}
{
"errorCode": "400xx",
"errorMessage": "similarity must be a number between 0 and 1"
}
{
"errorCode": "400xx",
"errorMessage": "speed must be a number between 0.7 and 1.2"
}
{
"errorCode": "400xx",
"errorMessage": "model_id is required"
}
{
"errorCode": "400xx",
"errorMessage": "file is required and must be of audio type"
}
401 Unauthorized
{
"errorCode": "40101",
"errorMessage": "Invalid or missing API key"
}
402 Payment Required
{
"errorCode": "40201",
"errorMessage": "Insufficient wallet balance"
}
500 Internal Server Error
{
"errorCode": "50001",
"errorMessage": "Failed to generate voice preview"
}
Example Usage
JavaScript
const formData = new FormData();
const audioFile = document.querySelector('input[type="file"]').files[0];
formData.append("file", audioFile);
formData.append("text", "مرحبا بك في فصيح، هذا صوتي الجديد");
formData.append("similarity", "0.8");
formData.append("model_id", "faseeh-v1-preview");
formData.append("speed", "1.0");
const response = await fetch('https://api.faseeh.ai/api/v1/voices/preview', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
// Note: Content-Type is set automatically by FormData
},
body: formData,
});
if (response.ok) {
// Handle streaming audio response
const reader = response.body.getReader();
const audioChunks = [];
while (true) {
const { done, value } = await reader.read();
if (done) break;
audioChunks.push(value);
}
// Combine chunks and create audio blob
const audioBlob = new Blob(audioChunks, { type: 'audio/raw' });
const audioUrl = URL.createObjectURL(audioBlob);
// Use audioUrl to play the preview
} else {
const error = await response.json();
console.error('Error:', error);
}
Python
import requests
url = "https://api.faseeh.ai/api/v1/voices/preview"
headers = {
"x-api-key": "YOUR_API_KEY"
}
with open("source_audio.wav", "rb") as audio_file:
files = {"file": audio_file}
data = {
"text": "مرحبا بك في فصيح، هذا صوتي الجديد",
"similarity": "0.8",
"model_id": "faseeh-v1-preview",
"speed": "1.0"
}
response = requests.post(url, files=files, data=data, headers=headers, stream=True)
if response.status_code == 200:
# Save streaming audio
with open("voice_preview.pcm", "wb") as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print("Voice preview saved successfully")
else:
print(f"Error: {response.status_code} - {response.text}")
cURL
curl -X POST "https://api.faseeh.ai/api/v1/voices/preview" \
-H "x-api-key: YOUR_API_KEY" \
-F "file=@source_audio.wav" \
-F "text=مرحبا بك في فصيح، هذا صوتي الجديد" \
-F "similarity=0.8" \
-F "model_id=faseeh-v1-preview" \
-F "speed=1.0" \
--output voice_preview.pcm
Voice Preview: This endpoint generates a preview of a cloned voice. If you’re satisfied with the preview, you can proceed to create it as a permanent voice using the voice creation endpoint.
API key for authentication
Text to generate preview with (minimum 3 words, 10 characters)
Voice similarity to source (0.0 to 1.0). Higher values produce more similar voice
Required range: 0 <= x <= 1
The model identifier to use for generation
Audio file containing the voice to preview
Speech speed (0.7 to 1.2, default 1.0)
Required range: 0.7 <= x <= 1.2
Streaming PCM16 audio preview
PCM16 audio stream (24000 Hz, Mono, 16-bit)