问题
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