Javascript Google Translate API text-to-speech:禁止http请求
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30599797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Translate API text-to-speech: http requests forbidden
提问by Growler
I am making a language learning web app that when you hover over the word, it pronounces it for you. I'd like to access the native speaker translations from Google Translate API.
我正在制作一个语言学习网络应用程序,当您将鼠标悬停在单词上时,它会为您发音。我想从 Google Translate API 访问母语人士的翻译。
I've found this resourcewhich gives http://translate.google.com/translate_ttsas the base URL and tlfor target language and qfor the query string.
我找到了这个资源,它提供http://translate.google.com/translate_tts了基本 URL、tl目标语言和q查询字符串。
This works awesome when I just access it in the browser, http://translate.google.com/translate_tts?tl=zh-CN&q=你好, but any httprequests for my app return a 403 Forbidden error.
当我只是在浏览器中访问它时,这很棒, 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+worldResolving translate.google.com... 173.194.123.38, 173.194.123.36, 173.194.123.32, ... Connecting to translate.google.com|173.194.123.38|:80... connected. HTTP request sent, awaiting response... 403 Forbidden 2015-06-02 11:02:07 ERROR 403: Forbidden.
本地主机:~ 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 禁止 2015-06-02 11:02:07 错误 403:禁止。
Is there a formal Google API for text-to-speech associated with their payment plans for traditional Google Translate API that I'm just not finding? Or is there a way to getand play this audio somehow?
是否有正式的 Google API 用于文本到语音转换,与我找不到的传统 Google Translate API 的付款计划相关联?或者有没有办法以get某种方式播放这个音频?
采纳答案by Akshat
That resource is dated. Google deprecated free access to the language translate api. Now an API key is needed. The api is also now in V2.
该资源已过时。Google 弃用了对语言翻译 API 的免费访问。现在需要一个 API 密钥。api 现在也在 V2 中。
Without an api key you will receive the 403 forbidden error.
如果没有 api 密钥,您将收到 403 禁止错误。
More information here: https://cloud.google.com/translate/docs
更多信息请访问:https: //cloud.google.com/translate/docs
回答by Tan Nguyen
You can get anything sound, I found it: https://translate.google.com.vn/translate_tts?ie=UTF-8&q=ANYTHING_TEXT&tl=en&client=tw-obNote: client=tw-ob
你可以得到任何声音,我发现它: https: //translate.google.com.vn/translate_tts?ie=UTF-8 & q=ANYTHING_TEXT&tl=en & client=tw-ob注意:client=tw-ob

