TTS quickstart

Overview

Synthesize spoken audio from text with natural, human-like Indic voices using Bhashini's inference pipeline.

Getting started

  1. Get an inference API key from the Bhashini developer portal.
  2. Choose a TTS service ID (e.g., AI4Bharat Indic-TTS or IIT-M voices).
  3. Provide input text in the supported source language script.
  4. Receive base64-encoded audio (WAV format) in the response.

Key configuration options

  • Gender: Select "female" or "male" voice in config.gender.
  • Speed: Adjust rate factor (e.g. 1.0 for normal, 1.25 for 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
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
curl --location 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline' \
--header 'Accept: */*' \
--header 'Authorization: YOUR_INFERENCE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"pipelineTasks": [
{
"taskType": "tts",
"config": {
"serviceId": "",
"language": {
"sourceLanguage": "hi"
},
"gender": "female",
"speed": 1
}
}
],
"inputData": {
"input": [
{
"source": "<text>"
}
]
}
}'
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));