This is a Python interface to Bhashini API, a powerful language service for Indian languages.
Install bhashini_translator
package.
pip install bhashini_translator
Befrore you can use it, you need to get necessary authentication details:
- Sign up, register and verify your email here.
- Go to the profile section and generate API key.
- Copy
userId
,ulcaApiKey
andInferenceApiKey
. All these values must be set inenvironment
(usingdotenv
or any other way) for this to work.
from bhashini_translator import Bhashini
Translate text:
bhashini = Bhashini(sourceLanguage, targetLanguage)
bhashini.translate(text)
Text to speech, returns a base64 encoded string:
bhashini = Bhashini(sourceLanguage)
base64String = bhashini.tts(text)
Automatic speech recognition and translation to text, in target language:
bhashini = Bhashini(sourceLanguage, targetLanguage)
text = bhashini.asr_nmt(base64String)
Bashini expects us to use ISO-639 series language codes.
Here is the list of languages supported by the IndicTrans2 models:
Assamese (asm_Beng) | Kashmiri (Arabic) (kas_Arab) | Punjabi (pan_Guru) |
Bengali (ben_Beng) | Kashmiri (Devanagari) (kas_Deva) | Sanskrit (san_Deva) |
Bodo (brx_Deva) | Maithili (mai_Deva) | Santali (sat_Olck) |
Dogri (doi_Deva) | Malayalam (mal_Mlym) | Sindhi (Arabic) (snd_Arab) |
English (eng_Latn) | Marathi (mar_Deva) | Sindhi (Devanagari) (snd_Deva) |
Konkani (gom_Deva) | Manipuri (Bengali) (mni_Beng) | Tamil (tam_Taml) |
Gujarati (guj_Gujr) | Manipuri (Meitei) (mni_Mtei) | Telugu (tel_Telu) |
Hindi (hin_Deva) | Nepali (npi_Deva) | Urdu (urd_Arab) |
Kannada (kan_Knda) | Odia (ory_Orya) |