Skip to navigation

Set the language

View as Markdown

The language_code parameter tells Bulbul which language your text is in. It is required on every request and is used for text normalization (numbers, abbreviations and symbols) before the speech is synthesized.

ParameterTypeRequiredValuesModelsAPIs
language_codestringYesOne of the 11 codes belowbulbul:v4-flash, bulbul:v3REST, HTTP stream, WebSocket

Supported languages

Languagelanguage_code
English (India)en-IN
Hindihi-IN
Bengalibn-IN
Tamilta-IN
Telugute-IN
Kannadakn-IN
Malayalamml-IN
Marathimr-IN
Gujaratigu-IN
Punjabipa-IN
Odiaod-IN

Example

import os
from sarvamai import SarvamAI
from sarvamai.play import save
client = SarvamAI(api_subscription_key=os.environ["SARVAM_API_KEY"])
response = client.text_to_speech.convert(
text="नमस्ते, सर्वम एआई में आपका स्वागत है।",
language_code="hi-IN",
model="bulbul:v4-flash",
speaker="kavya_hi_conversational",
)
save(response, "output.wav")

On WebSocket, set the language in the configure message (target_language_code in the Python SDK). See the WebSocket API.

Tips

  • Match the code to the text. language_code drives normalization, and normalization rules are language-specific.
  • Write Indic words in native script. Romanised Indic text (for example, “namaste”) degrades quality. Code-mixed text works, such as Hindi with English words: मेरा order कल deliver होगा।
  • The voice does not limit the language. On bulbul:v4-flash, the language tag in a persona ID (kavya_hi_conversational) is not a restriction: any supported language_code works with any persona. v4 has dedicated personas for nine of the languages. Malayalam and Odia work with any persona.
  • Choose a speaker per language. See recommended speakers by language.

Common errors

RequestError
language_code is null or an unsupported valueHTTP 400: Validation Error(s): - language_code: Input should be 'bn-IN', 'en-IN', 'gu-IN', 'hi-IN', 'kn-IN', 'ml-IN', 'mr-IN', 'od-IN', 'pa-IN', 'ta-IN' or 'te-IN'.