【问题标题】:Google TTS- Has anyone had any luck with it recently?谷歌 TTS-最近有没有人运气好?
【发布时间】: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


    【解决方案1】:

    您可以为可用的 python 安装 gtts 包。然后通过使用它,您可以将文本保存在 mp3 文件中然后播放。我用 gtts 打招呼的一个简单例子是

    tts = gTTS(text=, lang="en")
    tts.save("hello.mp3")
    os.system("mpg321 hello.mp3")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-31
      • 2012-04-03
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多