Text to Speech Preview a voice

Preview a voice

Generate a preview of a cloned voice from a source audio file. Upload the audio, provide the text to speak, and stream back PCM16 audio — before committing to a permanent voice.

1

Endpoint

POST /api/v1/voices/preview

Requires API key authentication via the x-api-key header. The request is multipart/form-data.

2

Request

Form dataContent-Type: multipart/form-data

FieldTypeRequiredDescription
textstringYesText to generate preview with (minimum 3 words, 10 characters)
similaritynumberYesVoice similarity to source (0.0 to 1.0). Higher values produce more similar voice
model_idstringYesThe model identifier to use for generation
speednumberNoSpeech speed (0.7 to 1.2, default 1.0). Values below 1.0 slow down speech, above 1.0 speed it up
fileFileYesAudio file containing the voice to preview
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.
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. The default stays 24000 for backward compatibility — pass sample_rate=48000 for the best quality.
3

Example request

Upload a source recording and stream the preview audio back.

curl
curl -X POST "https://api.munsit.com/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" \ -F "sample_rate=48000" \ --output voice_preview.pcm
4

Response

Status code: 200 OK. The body is streaming PCM16 audio, mono, 16-bit, at the rate you requested — 24000 Hz by default, or 48000 when you pass sample_rate=48000 (recommended). The resolved rate is always echoed in the Content-Type header, so a client can follow it rather than assume.

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

Error responses

Errors come back as JSON with an errorCode and errorMessage.

StatusError codeExample message
400 Bad Request400xxtext is required
400 Bad Request400xxsimilarity must be a number between 0 and 1
400 Bad Request400xxspeed must be a number between 0.7 and 1.2
400 Bad Request400xxmodel_id is required
400 Bad Request400xxfile is required and must be of audio type
401 Unauthorized40101Invalid or missing API key
402 Payment Required40201Insufficient wallet balance
500 Internal Server Error50001Failed to generate voice preview
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.
6

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.