python将文字翻译成语音 [英] python text translation to speech

查看:260
本文介绍了python将文字翻译成语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试文本翻译 (从英语到其他语言),并使用python翻译为音频代码.我正在使用Google Translation API进行翻译,并使用Win32进行音频处理. 在测试时,我发现Google支持 https://gist.github.com/jseabold/1473363 这些语言.代码的翻译部分似乎可以在许多选项上正常工作,但是音频部分仅适用于几种语言(英语,西班牙语,意大利语等).

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).

如您在下面的示例中看到的,我可以看到文本正确地翻译成北印度语,但我没有音频输出.我觉得wincl.dispatch在Google翻译时不支持所有语言.此外,我无法找到有关支持的语言的win32 api的详细信息.您能帮我找到此列表还是将其显示为印地文音频解决方案吗?

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?

谢谢

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仅支持已安装的语音.由于Microsoft没有印地语TTS语音,因此您将需要在其他地方寻找兼容SAPI的印地语TTS语音或支持印地语TTS的Web服务.网页搜索将帮助您进行选择.

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.

这篇关于python将文字翻译成语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆