Text to Speech Audio streaming output

Audio streaming output

Generate speech from Arabic text with streaming PCM16 audio output. When streaming: true is set, audio chunks are streamed as they're generated — low-latency delivery you can start playing before generation completes.

1

How it works

When streaming is enabled:

StepWhat happens
1The API starts generating audio immediately
2Audio chunks are sent as they become available
3You can begin playback before generation completes
4Lower latency compared to non-streaming requests
2

Audio format

Streaming responses return raw PCM audio data:

PCM1648000 Hz recommended24000 Hz defaultmono16-bit
PropertyValue
FormatPCM (Pulse Code Modulation)
Sample rateFollows sample_rate: 48000 Hz recommended (engine-native), 24000 Hz default
ChannelsMono
Bit depth16-bit
3

Endpoint & request

POST /api/v1/text-to-speech/{model_id}

Requires API key authentication via the x-api-key header. Same endpoint as Synthesize — the only difference is streaming must be true.

Path parameters

ParameterTypeRequiredDescription
model_idstringYesThe model identifier to use for generation

Request bodyContent-Type: application/json

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
speednumberNoSpeech speed (0.7 to 1.2, default 1.0). Values below 1.0 slow down speech, above 1.0 speed it up
streamingbooleanYesMust be true for streaming response
sample_ratenumberNoOutput sample rate in Hz, 800048000 (default 24000). Use 48000 — it's the engine's native rate, so the audio skips downsampling and needs no client-side resampling for WebRTC.
dialectstringNoDialect hint for synthesis: auto (default), emirati, or fusha.
4

Example request

The cURL example uses the faseeh-v1-preview model with the ar-najdi-male-2 voice.

curl
curl -X POST "https://api.munsit.com/api/v1/text-to-speech/faseeh-v1-preview" \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "voice_id": "ar-najdi-male-2", "text": "مرحبا بك في فصيح", "streaming": true, "stability": 0.5, "speed": 1 }' \ --output audio.pcm
5

Response

Status code: 200 OK. The body is a stream of mono PCM16 audio chunks at the rate you requested — 24 kHz by default, 48 kHz when you pass sample_rate=48000 (recommended). The resolved rate is echoed in the Content-Type header, so a client can follow it rather than assume.

HeaderValue
Content-Typeaudio/raw;codec=pcm16;rate=<sample_rate>;channels=1 — e.g. rate=48000
Cache-Controlno-cache
Connectionkeep-alive

Handling streaming responses. Process the streaming PCM data in your application: save chunks to a buffer, play audio chunks as they arrive, and convert PCM to your desired format (WAV, MP3, etc.) if needed.

6

Error responses

Errors come back as JSON with an errorCode and errorMessage.

StatusError codeExample message
400 Bad Request400xxModel not found: invalid_model_id
402 Payment Required402xxInsufficient wallet balance. Required: $0.05, Available: $0.02
7

Cost calculation

The cost is calculated from the text length (number of characters) and the 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 Munsit dashboard.
8

Go further

Working with an AI assistant? Every page is available as Markdown: add .md to the URL, or send an Accept: text/markdown header. For the whole documentation in one request, point it at llms-full.txt; the page index is llms.txt. Or use Copy Page, top right.