Voice Changing

Bhashini Text-to-Speech (TTS) models support multiple voices and speaker characteristics across 22+ Indian languages. You can customize the voice persona either by setting the gender field in the pipeline configuration or by selecting a voice-specific serviceId.

Selecting Voice Gender

Configure the gender field inside your pipeline task config to toggle between male and female acoustic models:

Config with gender
{
  "pipelineTasks": [
    {
      "taskType": "tts",
      "config": {
        "language": {
          "sourceLanguage": "hi"
        },
        "serviceId": "ai4bharat/indic-tts-coqui-indo_aryan-gpu--t4",
        "gender": "female"
      }
    }
  ],
  "inputData": {
    "input": [
      {
        "source": "नमस्ते, भाषिणी में आपका स्वागत है।"
      }
    ]
  }
}

Supported Gender Values

ParameterTypeAllowed ValuesDefaultDescription
genderstring"female", "male""female"The speaker voice characteristic to synthesize.

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' // 'female' or 'male'
      }
    }
  ],
  inputData: {
    input: [{ source: 'नमस्ते, भाषिणी में आपका स्वागत है।' }]
  }
};


const response = await fetch(url, {
  method: 'POST',
  headers: {
    'Authorization': '<YOUR_INFERENCE_API_KEY>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(payload)
});


const data = await response.json();
const audioBase64 = data.pipelineResponse[0].audio[0].audioContent;


// Play directly in browser
const audio = new Audio(`data:audio/wav;base64,${audioBase64}`);
audio.play();

Live Interactive Tryout

Test switching between female and male voices live using the runner below:

Try Voice Gender Selection
Switch between male and female voices (service must support gender)
Request
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"
}
}
],
"inputData": {
"input": [
{
"source": "<text>"
}
]
}
}'
Response
Send a request to see the live response here.

Related Guides