Skip to navigation

How to specify language codes

View as Markdown

The language_code parameter tells the STT model which language to expect in the audio. Using the correct language code improves transcription accuracy.

Supported Languages (Saaras v4)

Saaras v4 supports 22 Indian languages with BCP-47 format codes and additionally recognizes Global English alongside Indian English (en-IN):

LanguageCodeLanguageCode
Hindihi-INAssameseas-IN
Bengalibn-INUrduur-IN
Kannadakn-INNepaline-IN
Malayalamml-INKonkanikok-IN
Marathimr-INKashmiriks-IN
Odiaod-INSindhisd-IN
Punjabipa-INSanskritsa-IN
Tamilta-INSantalisat-IN
Telugute-INManipurimni-IN
Englishen-INBodobrx-IN
Gujaratigu-INMaithilimai-IN
Dogridoi-IN

Automatic Language Detection

To enable automatic language detection, pass unknown as the language_code parameter. The model will detect the language from the audio.

Best Practice: Always specify the language code when you know the language of the audio. This improves accuracy and reduces processing time. Use unknown only when the language is truly unknown.

Example Code

The examples below use saaras:v4, which supports the 22 Indian languages and also recognizes Global English alongside Indian English. It also supports keyterm prompting.

from sarvamai import SarvamAI
client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
# Specify language for better accuracy
response = client.speech_to_text.transcribe(
file=open("audio.wav", "rb"),
model="saaras:v4",
language_code="ta-IN", # Tamil
mode="transcribe",
keyterms=["Sarvam", "New Delhi", "Vistaar"]
)
print(response.transcript)

keyterms is supported only on saaras:v4. Up to 50 terms, 64 characters each. See Keyterm Prompting.