我一直在尝试在我的Raspberry Pi 2上安装一个类似于"JARVIS“的系统。我对eSpeak、节日和野餐都做了一些修改,但我发现皮科是其中最好的。
然而,野餐是非常无聊的听,是完全单调的。一些网站有2013-14年的帖子,用户可以使用谷歌翻译的TTS。然而,谷歌最近改变了他们的一些政策,使这些非官方的应用程序不能工作,所以现在它要求一个CAPTCHA和HTTP 503错误。
这是我在一个网站上发现的代码的一个例子,这些代码曾经工作过,但自从谷歌的政策改变之后就停止了。
#!/usr/bin/python
import urllib, pycurl, os
def downloadFile(url, fileName):
fp = open(fileName, "wb")
curl = pycurl.Curl()
curl.setopt(pycurl.URL, url)
curl.setopt(pycurl.WRITEDATA, fp)
curl.perform()
curl.close()
fp.close()
def getGoogleSpeechURL(phrase):
googleTranslateURL = "http://translate.google.com/translate_tts? tl=en&"
parameters = {'q': phrase}
data = urllib.urlencode(parameters)
googleTranslateURL = "%s%s" % (googleTranslateURL,data)
return googleTranslateURL
def speakSpeechFromText(phrase):
googleSpeechURL = getGoogleSpeechURL(phrase)
downloadFile(googleSpeechURL,"tts.mp3")
os.system("mplayer tts.mp3 -af extrastereo=0 &")
speakSpeechFromText("testing, testing, 1 2 3.")
有没有人对谷歌TTS有任何进展?
发布于 2016-06-14 09:01:41
您可以为python安装gtts包。然后,通过使用它,您可以将文本保存在mp3文件中,然后播放它。一个简单的例子是,我使用gtts来向世界问好
tts = gTTS(text=, lang="en")
tts.save("hello.mp3")
os.system("mpg321 hello.mp3")
https://stackoverflow.com/questions/37817950
复制