ALD quickstart
Overview
Audio Language Detection (ALD) analyzes spoken audio clips and identifies the primary Indic language spoken, enabling intelligent routing to language-specific ASR engines.
Getting started
- Get an inference API key from the Bhashini portal.
- Choose an ALD service ID from the models directory.
- Send base64-encoded audio (16 kHz mono WAV/MP3).
- Receive detected language codes along with model confidence scores.
Audio guidelines & accuracy tips
- Optimal duration:
2.5 to 5.0 seconds. Short utterances under 1 second have insufficient phonetic variety and may yield low confidence. - Sample rate:
16 kHz Monois recommended. - Language predictions: The model returns ranked language hypotheses with normalized probability scores.
Real-world use case: Dynamic ASR Router
In automated call centers and multilingual voice assistants, use ALD as the entry gate:
# Route audio dynamically based on detected language
lang = ald_result["pipelineResponse"][0]["output"][0]["langPrediction"][0]["langCode"]
confidence = ald_result["pipelineResponse"][0]["output"][0]["langPrediction"][0]["langScore"]
print(f"Detected: {lang} with {confidence*100:.1f}% confidence")
asr_service_id = LANGUAGE_ASR_REGISTRY.get(lang, DEFAULT_ASR_ID)Interactive playground
Try Audio Language Detection
Paste or upload base64 audio and detect spoken language
Request
Select model
Choose audio file
audio or video (wav, flac, mp3, m4a, aac, ogg, webm, mp4, mov) · max 120 sAudio (base64)
Add an inference API key to run.
curl
Response
Send a request to see the live response here.
Code examples
import fs from "fs";
const url = 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline';
const audioBase64 = fs.readFileSync("voice_clip.wav").toString("base64");
const payload = {
pipelineTasks: [{
taskType: 'ald',
config: { serviceId: '<ALD_SERVICE_ID>' }
}],
inputData: {
audio: [{ audioContent: audioBase64 }]
}
};
const res = await fetch(url, {
method: 'POST',
headers: {
'Accept': '*/*',
'Authorization': '<YOUR_INFERENCE_API_KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
const data = await res.json();
console.log(data.pipelineResponse[0].output[0].langPrediction);