Generate Speech
Beta. Generates speech in a cloned voice.
Provide exactly one of:
voice_id— a saved cloned voice fromPOST /voices/create(or Content Studio), orref_audio— a reference audio clip uploaded with this request (optionalref_texttranscript).
Sending both returns 400. A saved voice_id avoids re-uploading the clip on every call.
Accepts multipart/form-data.
Base URL: https://api.sarvam.ai.
Auth: send your key in the api-subscription-key header (recommended); Authorization: Bearer <key> is also accepted.
The cloned voice is cross-lingual: the reference clip’s language does not need to match language_code.
Billing: charged per character of text against the text_to_speech_voice_cloning API. See the pricing page.
Authentication
Request
Saved cloned voice ID (svc-{uuid}) from POST /voices/create or Content Studio. Exactly one of ref_audio or voice_id must be provided — sending both returns 400. Prefer voice_id when you already saved the voice so you do not re-upload the clip.
Reference audio clip used to clone the voice for this request. Supported formats: WAV, MP3, FLAC, OPUS, AAC, MULAW, ALAW, LINEAR16. WAV is recommended.
Limits: max file size 10 MB; max duration 15 seconds; single speaker. Exactly one of ref_audio or voice_id must be provided — sending both returns 400.
Optional transcript of ref_audio (max 500 characters). Improves fidelity when provided. Omit or leave empty to let the API transcribe the clip. Ignored when voice_id is used.
Text to synthesize in the cloned voice. Native scripts and code-mixed text are supported. Maximum 1000 characters; longer text is rejected with a 400. Split longer input client-side and synthesize it in parts.
BCP-47 language code for the synthesized output. The cloned voice can speak any supported language, regardless of the reference clip’s language (cross-lingual cloning).
Available Options:
as-IN: Assamesebn-IN: Bengalien-IN: English (Indian)gu-IN: Gujaratihi-IN: Hindikn-IN: Kannadaml-IN: Malayalammr-IN: Marathiod-IN: Odiapa-IN: Punjabita-IN: Tamilte-IN: Telugu
Speech speed multiplier. 1.0 is natural speed; 0.5 to 2.0 is accepted. Speed is adjusted without changing pitch. Mutually exclusive with max_audio_duration - sending both returns a 400 error.
Audio codec for the output audio. Default is wav.
wav: Uncompressed. Best quality for downstream processing.mp3: Smaller file size; suitable for web playback.flac: Lossless compression.opus: Low-bitrate codec ideal for streaming. Whenspeech_sample_rateis explicitly set withopus, it must be one of 8000, 16000, 24000 or 48000 Hz; when omitted, opus output is returned at the native 24000 Hz.aac: Common in mobile and broadcast.linear16: Raw 16-bit PCM.mulaw/alaw: 8-bit telephony codecs for IVR pipelines.
Output sample rate in Hz. Supported values are 8000, 16000, 22050, 24000, 32000, 44100, 48000. If omitted, the API returns 24000 Hz. This is a service-side default: the output is resampled to it, so it does not change with the generating model. Set it to match your downstream pipeline: 8000 for telephony/IVR, 16000 for voice agents, 24000 for web playback, 44100/48000 for broadcast.
Run the quality-control pipeline. Off by default. When enabled, the generated audio is transcribed and verified before the response is returned, which adds latency — roughly half a second for single-script text, and several seconds for code-mixed text.
Enable response caching. Coming soon - accepted for forward compatibility, currently ignored.
Enable VAD-based silence trimming of the generated audio. Default is true. Applies to single-chunk (short) generations; long text that is split into sentence chunks is returned untrimmed.
Enable pre-TTS text normalization: numbers, currencies and dates are converted to their spoken form before synthesis (e.g. 9840950950 becomes the spoken digit sequence). Defaults to the server-side setting. Supported for all 12 languages accepted by language_code; any other code passes through unchanged.
Maximum output audio duration in seconds. If the generated audio is longer, it is time-stretched to fit. Must be >= min_audio_duration. Silently floored to the reference clip’s duration when the clip is longer. Mutually exclusive with pace - sending both returns a 400 error.
Override for the reference audio duration in seconds. Useful for dubbing/sync scenarios where the model should treat the reference as a specific length.
Response
Base64-encoded output audio in the requested codec. Decode client-side before playback or storage.
Alias of audio_b64, same value. Retained for callers written against it; prefer audio_b64.