带有付费帐户的谷歌 tts [英] google tts with paid account

查看:24
本文介绍了带有付费帐户的谷歌 tts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您现在必须付费才能使用谷歌翻译 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();      
  }
}

但是当我做 new GoogleTranslate().speak("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?

推荐答案

我还没有尝试过你的代码,所以我不确定你是否应该在播放它之前等待声音加载(很可能),但我最近写了一篇关于此服务的文章.这里重要的部分如下:

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 标头(这意味着它告诉服务您单击了链接的哪个页面),那么 [Google] 将返回 404(未找到)http 错误...

在此处阅读整篇文章:嵌入文本-to-speech 到 HTML5 游戏

所以实际上服务还在,你只需要隐藏你的referer header.一种方法是通过创建一个小的网关脚本.文章中有一项权利的来源.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆