谷歌与TTS付费帐户 [英] google tts with paid account
问题描述
您现在必须付费使用谷歌翻译API。我很高兴地支付服务,但我不能找到一种方法,使用TTS。这是我在做什么。
You now have to pay to use the google translate api. I'm happy to pay for the service but I can't find a way to use the tts. This is what I'm doing
var GoogleTranslate = function(){
var key = "myapikey"
this.speak = function(words) {
var url = "http://translate.google.com/translate_tts?tl=es&q=" + escape(words) + "&key=" + key
new Audio(url).play();
}
}
但是当我做新GOOGLETRANSLATE()。说话(HOLA)
but when I do new GoogleTranslate().speak("hola")
要 http://translate.google.com/translate_tts的请求从未返回响应。我如何得到这个工作?
The requests to http://translate.google.com/translate_tts never return a response. How do I get this working?
推荐答案
我没试过你的code,所以我不知道,如果你要等待声音加载之前你可以玩(最有可能),但我最近写的关于这项服务的文章。这里重要的部分是:
I haven't tried your code yet, so I'm not sure if you should be waiting for the sound to load before you can play it (most likely), but I've written an article about this service recently. The part that matters here is the following:
的 ...如果你的浏览器与转发不是一个空字符串以外的任何值Referer头(这意味着它会告诉你点击了该链接的页面服务),然后[谷歌]会返回404(未找到) HTTP错误... 的
在这里阅读整篇文章:嵌入文本-to-语音转换成HTML5游戏
Read the entire article here: Embedding text-to-speech into HTML5 games
所以,事实上,该服务仍然存在,你只需要隐藏自己的参照标头。做到这一点的方法之一是通过创建一个较小的网关脚本。还有的文章在一个正确的来源。
So in fact, the service is still there, you just need to hide your referer header. One way to do that is through creating a small gateway script. There's the source for one right in the article.
这篇关于谷歌与TTS付费帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!