【发布时间】:2016-06-14 16:53:13
【问题描述】:
我一直在我的 Raspberry Pi 2 上尝试使用类似“JARVIS”的系统。我尝试过使用 eSpeak、Festival 和 pico,但我发现 pico 是其中最好的。
但是,pico 听起来很乏味,完全单调。一些网站有 2013-14 年的帖子,其中用户可以使用谷歌翻译的 TTS。然而,最近谷歌改变了他们的一些政策,所以这些非官方应用程序将无法运行,所以现在它要求一个验证码和一个 HTTP 503 错误。
这是我在一个网站上找到的代码示例,该网站曾经可以工作,但自从 Google 的政策更改后就停止了。
#!/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.")
有人对 Google TTS 有好运吗?
【问题讨论】:
标签: python bash raspberry-pi text-to-speech