Skip to navigation

Text-to-Speech Overview

View as Markdown

Sarvam AI text-to-speech turns text into natural speech in 11 Indian languages. It is powered by the Bulbul models:

  • Bulbul v4 Flash is the latest model, with 200+ persona voices. Use it for new integrations.
  • Bulbul v3 is the API default when model is omitted, with 37 named speakers.

Both models use the same request format, limits and APIs.

Building with an AI coding assistant? Install the Sarvam text-to-speech skill to generate correct TTS code:

npx skills add sarvamai/skills --skill text-to-speech

See Agent Skills for the full list.

Make Your First Request

Get an API key from the dashboard and set it as the SARVAM_API_KEY environment variable. Then send a request to the REST API. Each item in the audios array of the response is base64-encoded audio (WAV by default), so the examples decode it and save output.wav.

import os
from sarvamai import SarvamAI
from sarvamai.play import save
client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])
response = client.text_to_speech.convert(
text="Welcome to Sarvam AI!",
language_code="en-IN",
model="bulbul:v4-flash",
speaker="simran_en_customer",
)
save(response, "output.wav")

Want to hear the voices first? Browse audio samples for every speaker on the Voices page, or try your own text in the playground.

Choose an API

All three APIs use the same models, voices and parameters. They differ in how audio is delivered and how interactive the connection is.

Which one should I use?

  • The text is short and known up front: use REST.
  • You want playback to start sooner, or you are on a server or serverless runtime: use HTTP stream. You get audio you can pipe straight to a file or player.
  • You are building a voice agent, or sending text as an LLM produces it: use WebSocket. You keep one connection open across turns.

For a side-by-side comparison, see Which Text-to-Speech API to Use.

Common Parameters

These parameters work on all three APIs and on both models.

ParameterDescriptionValues
modelModel to usebulbul:v4-flash, bulbul:v3 (default)
speakerVoice to useA v4 persona ID or a v3 speaker name. See Voices
language_codeLanguage of the texthi-IN, en-IN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, od-IN, pa-IN, ta-IN, te-IN
paceSpeaking speed0.5 to 2.0
pitchVoice pitch-0.5 to 0.5
loudnessVolume0.1 to 2.5
temperatureExpressiveness and variation0.01 to 1.0
speech_sample_rateOutput sample rate in HzSee Limits
output_audio_codecOutput formatSee Audio Formats
dict_idPronunciation dictionary to applyA dictionary ID

Audio Formats

Set the format with output_audio_codec. All formats work on REST, HTTP stream and WebSocket.

FormatContent typeNotes
mp3audio/mpegDefault for HTTP stream and WebSocket
wavaudio/wavDefault for REST
aacaudio/aac
flacaudio/flacLossless
opusaudio/opusOgg container. Set speech_sample_rate to 8000, 16000, 24000 or 48000
linear16audio/pcmRaw 16-bit PCM
mulawaudio/mulawμ-law, common in telephony
alawaudio/alawA-law, common in telephony

Limits

LimitValue
REST: max characters per request2,500
HTTP stream: max characters per request3,500
WebSocket: max characters per message2,500 (under 500 recommended for the lowest latency)
Sample rates, REST8000, 16000, 22050, 24000, 32000, 44100, 48000
Sample rates, HTTP stream and WebSocket8000, 16000, 22050, 24000
Default sample rate22050 Hz
Rate limitsPer plan. See Rate Limits

Next Steps

Need help? Reach us on Discord.