Search code examples
pythongoogle-translation-api

Googletrans return Hindi translation in English Script


When trying to use the googletrans service for translating English text to Hindi, the output comes out in Hindi script. Is it possible for me to set the script to English?

For example

print(googletrans.Translator().translate('Tum kon ho?',src='hindi',dest='english').text)

returns output as 'Who are you?'

However, when I do this the other way

print(googletrans.Translator().translate('Who are you?',src='english',dest='hindi').text)

The output comes out to be 'तुम कौन हो?'

Is there any way to return this output as 'Tum kon ho?'


Solution

  • Within the object returned from the translate method their should be a property called "pronunciation"

    print(googletrans.Translator().translate('Who are you?',src='english',dest='hindi').pronunciation)