Generate speech audio from text using ASAT v2, short for ASAT Speaks Any Text. It is optimized around Moroccan Arabic and Arabic speech generation.
Canonical endpoint:
POST https://api.sawalni.com/v1/audio/speech
Sawalni-style alias:
POST https://api.sawalni.com/v1/speech/synthesize
Send an application/json request.
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | Text to synthesize into speech |
model | string | No | Model identifier. Use asat. Default: asat |
voice | string | No | Reference voice. Default: male-1 |
response_format | string | No | wav or pcm16. Default: wav |
stream | boolean | No | Send audio bytes as they are generated. Default: false. This changes delivery, not model quality. |
The current service does not expose NFE steps, speed, CFG, or chunk-size controls. Do not send those fields; the current server ignores extra request fields.
The service keeps one speech session for each request. stream: true delivers output chunks as they become available. It does not select a separate quality path. Use response_format: "pcm16" for raw signed 16-bit little-endian PCM at 24 kHz, mono. For a streamed WAV, the initial RIFF header has placeholder lengths. Rewrite the RIFF and data lengths after the stream ends before saving a standalone WAV file. The playground does this for you.
curl -X POST https://api.sawalni.com/v1/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "asat", "voice": "male-1", "response_format": "wav", "input": "السلام، كيف داير؟ هادي تجربة ديال الصوت بالدارجة المغربية." }' \ --output asat.wav
import requests response = requests.post( "https://api.sawalni.com/v1/audio/speech", headers={"Authorization": "Bearer YOUR_API_KEY"}, json={ "model": "asat", "voice": "male-1", "response_format": "wav", "input": "السلام، كيف داير؟", }, ) response.raise_for_status() open("asat.wav", "wb").write(response.content) print("Duration:", response.headers.get("x-audio-duration-s"))
const response = await fetch('https://api.sawalni.com/v1/audio/speech', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json', }, body: JSON.stringify({ model: 'asat', voice: 'male-1', response_format: 'wav', input: 'السلام، كيف داير؟', }), }); const audio = await response.blob(); new Audio(URL.createObjectURL(audio)).play(); console.log('Duration:', response.headers.get('x-audio-duration-s'));
The response body is audio/wav or raw 24 kHz mono signed 16-bit PCM. Metadata is returned in response headers. Some fields, including duration and processing time, are only available for buffered responses. For streams, calculate duration from PCM byte count at 48,000 bytes per second.
| Header | Description |
|---|---|
x-audio-duration-s | Generated audio duration in seconds (buffered responses) |
x-processing-ms | Server-side generation time in milliseconds (buffered responses) |
x-input-chars | Number of input characters processed |
x-asat-model | Public model identifier, asat |
x-asat-voice | Resolved reference voice |
x-asat-conditioning | Speech conditioning method used for this response |
x-audio-sample-rate | Output sample rate, currently 24000 |
x-audio-channels | Output channel count, currently 1 |
x-audio-codec | Output codec, currently pcm_s16le |
x-asat-preprocess | Text preprocessing applied by the Sawalni gateway |
Retrieve the current machine-readable catalog with GET https://api.sawalni.com/v1/voices. The voice request value must be one of these IDs:
| Voice | Description |
|---|---|
male-1 | Yassine |
male-2 | Mehdi |
male-3 | Anas |
male-4 | Amine |
male-5 | Hamza |
male-6 | Ayoub |
male-7 | Ilyas |
male-8 | Soufiane |
male-9 | Reda |
male-10 | Othmane |
male-11 | Zakaria |
male-12 | Youssef |
female-1 | Salma |
female-2 | Ghita |
female-3 | Kenza |
female-4 | Imane |
female-5 | Hajar |
female-6 | Zineb |
female-7 | Sara |
female-8 | Meryem |
female-9 | Asmae |
female-10 | Chaimae |
The service uses the selected voice for speech generation.
| Property | Value |
|---|---|
| Model ID | asat |
| Full Name | ASAT Speaks Any Text |
| Specialization | Moroccan Arabic and Arabic text-to-speech |
| HTTP Code | Meaning |
|---|---|
| 200 | Success — audio returned |
| 400 | Invalid input, model, voice, or response format |
| 503 | No healthy speech synthesis deployments |
| 504 | Speech synthesis timed out |
Speech synthesis is metered by generated audio duration.
| Metric | Rate |
|---|---|
| Generated audio seconds | $6.00 per 1M seconds |