Google tts with a paid account

Now you need to pay for using api. I am happy to pay for the service, but I can not find a way to use tts. This is what I do

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(); } } 

but when I do a new GoogleTranslate (), say ("hola")

Requests http://translate.google.com/translate_tts do not return a response. How to do it?

+1
source share
1 answer

I have not tried my code yet, so I'm not sure that you have to wait for the sound to load before you can play it (most likely), but I recently wrote an article about this service. The following part is important here:

... if your browser sends the Referer header with any value other than an empty line (this means that it tells the service which page you clicked on the link), then [Google] will return HTTP 404 (Not Found) error ...

Read the full article here: Embed Text to Speech in HTML5 Games

So, in fact, the service still exists, you just need to hide the header of your referrer. One way to do this is to create a small gateway script. There is a source for one right in the article.

+2
source

Source: https://habr.com/ru/post/927682/


All Articles