TTS quickstart
Overview
Synthesize spoken audio from text with natural, human-like Indic voices using Bhashini's inference pipeline.
Getting started
- Get an inference API key from the Bhashini developer portal.
- Choose a TTS service ID (e.g., AI4Bharat Indic-TTS or IIT-M voices).
- Provide input text in the supported source language script.
- Receive base64-encoded audio (WAV format) in the response.
Key configuration options
- Gender: Select
"female"or"male"voice inconfig.gender. - Speed: Adjust rate factor (e.g.
1.0for normal,1.25for faster delivery). - Audio format: Generates standard base64 PCM WAV audio (e.g., 22050 Hz / 48000 Hz).
Handling the audio response
The API returns audio as a base64 string under pipelineResponse[0].audio[0].audioContent. In JavaScript/Web apps, convert it directly to a playable audio element:
// Play base64 audio directly in browser
const audioBase64 = data.pipelineResponse[0].audio[0].audioContent;
const audio = new Audio("data:audio/wav;base64," + audioBase64);
audio.play();Interactive playground
Try TTS
Enter text and generate speech (configure voice gender and speed)
Request
Select model
हिन्दी | Hindi
Below 1 is slower and more deliberate, above 1 is quicker. Ignored by services that do not support it.
Add an inference API key to run.
curl
Response
Send a request to see the live response here.
Code examples
const url = 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline';
const payload = {
pipelineTasks: [{
taskType: 'tts',
config: {
language: { sourceLanguage: 'hi' },
serviceId: '<TTS_SERVICE_ID>',
gender: 'female'
}
}],
inputData: {
input: [{ source: 'नमस्ते' }]
}
};
fetch(url, {
method: 'POST',
headers: {
'Accept': '*/*',
'Authorization': '<YOUR_INFERENCE_API_KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => console.log(data));