python text translation to speech

不羁岁月 提交于 2019-12-24 08:19:04

问题


I am working on testing text translation (from English to other language) and translation to audio code using python. I am using google translate api for translation and win32 for audio. While testing i found that google supports https://gist.github.com/jseabold/1473363 these languages. The translation part of code seem to be working fine for many options but audio part only works with a few languages (english , spanish , italian etc works).

as you can see in example below I can see text is translated into Hindi correctly but i get no audio output. I feel that wincl.dispatch is not supporting all languages as google translate. furthurmore i could not find details on win32 api regarding supported languages. can you help me finding this list or in engilsh text to hindi audio solution?

thanks

from googletrans import Translator
import win32com.client as wincl
translator = Translator()



a=translator.translate('안녕하세요.')
a=translator.translate('I am robot',src='en',dest='hi')
print (a.text)
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Speak(a.text)


मैं रोबोट हूँ

Process finished with exit code 0

回答1:


SAPI only supports voices that are installed. Since Microsoft doesn't have a Hindi TTS voice, you will need to look elsewhere for either a SAPI-compliant Hindi TTS voice, or a web service that supports Hindi TTS. A web search will help you with your selection.



来源:https://stackoverflow.com/questions/49945874/python-text-translation-to-speech

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!