简体   繁体   English

python将文字翻译成语音

[英]python text translation to speech

I am working on testing text translation (from English to other language) and translation to audio code using python. 我正在测试文本翻译(从英语到其他语言)以及使用python翻译到音频代码的工作。 I am using google translate api for translation and win32 for audio. 我正在使用Google Translation API进行翻译,并使用Win32进行音频处理。 While testing i found that google supports https://gist.github.com/jseabold/1473363 these languages. 在测试时,我发现Google支持https://gist.github.com/jseabold/1473363这些语言。 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. 我觉得wincl.dispatch在Google翻译时不支持所有语言。 furthurmore i could not find details on win32 api regarding supported languages. 此外,我找不到有关支持的语言的win32 api的详细信息。 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

SAPI only supports voices that are installed. SAPI仅支持已安装的语音。 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. 由于Microsoft没有印地语TTS语音,因此您将需要在其他地方寻找兼容SAPI的印地语TTS语音或支持印地语TTS的Web服务。 A web search will help you with your selection. 网络搜索将帮助您进行选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM