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
| Parameter | Type | Allowed Values | Default | Description |
|---|---|---|---|---|
gender | string | "female", "male" | "female" | The speaker voice characteristic to synthesize. |
Note
Voice gender availability depends on the specific TTS model service. Most deployed AI4Bharat and IIT-Madras Indic-TTS models provide both male and female acoustic checkpoints for all major scheduled languages.
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
Select model
हिन्दी | Hindi
Add an inference API key to run.
curl
Response
Send a request to see the live response here.
Related Guides
- TTS Quickstart — Complete guide to onboarding and making your first TTS call.
- Speed Changing — Adjust speech cadence and playback speed factor.
- TTS Capability Suite — Full JSON schema for TTS compute requests and responses.