Google翻译API文字转语音:http请求被禁止

时间:2015-06-02 15:05:07

标签: javascript google-api text-to-speech http-status-code-403 google-translate

我正在制作一个语言学习网络应用程序,当您将鼠标悬停在该单词上时,它会为您发音。我想访问Google Translate API的母语翻译。

我找到this resource,其中http://translate.google.com/translate_tts为基本网址,tl为目标语言,q为查询字符串。

当我在浏览器中访问它时,这很棒 http://translate.google.com/translate_tts?tl=zh-CN&q =你好,但我的应用的任何httprequests都会返回403 Forbidden错误。

  

localhost:~me $ wget   “http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world”   --2015-06-02 11:02:06-- http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world   解析translate.google.com ... 173.194.123.38,173.194.123.36,   173.194.123.32,...正在连接到translate.google.com | 173.194.123.38 |:80 ...已连接。 HTTP请求   发送,等待回复...... 403 Forbidden 2015-06-02 11:02:07错误   403:禁止。

是否有正式的Google API用于与传统Google Translate API的付款计划相关联的文字转语音,我只是没有找到?或者有没有办法get并以某种方式播放此音频?

2 个答案:

答案 0 :(得分:4)

该资源已过时。谷歌不赞成免费使用语言翻译api。现在需要API密钥。 api现在也在V2。

如果没有api密钥,您将收到403禁止错误。

此处提供更多信息:https://cloud.google.com/translate/docs

答案 1 :(得分:3)

你能听到任何声音,我发现了: https://translate.google.com.vn/translate_tts?ie=UTF-8&q=ANYTHING_TEXT&tl=en&client=tw-ob 注意: client = tw-ob