Google Translate TTS problem

I am testing a simple HTML file that contains:

<audio src="http://translate.google.com/translate_tts?tl=en&q=A+simple_text+to+voice+demonstration." controls autoplay>

with Chrome v11.0.696.68 and FF v4.0.1. I go through a proxy server and it does not work. Nothing plays, and clicking the play button doesn’t work in Chrome. In FF, it blinks and then shows an “X” above the control. Error logs show nothing.

So I broke the steps:

  • Entering a URL into any browser works

  • wget -q -U Mozilla -O / tmp / tts.mp3 "http://translate.google.com/translate_tts?tl=en&q=Welcome+to+our+fantastic+text+to + voice + demo". gets a file that plays perfectly in both browsers.

  • If I serve this file from my local web server, it works fine (i.e. the one that does not go through the proxy). those. src = "http: //localhost/tts.mp3"

I'm at a dead end. If the proxy server was the problem, then wget and the address bar should not work. If src is a url, this is a problem, so it should not work from my local server.

Any clues? offers?

+4
source share
2 answers

The reason this does not work is most likely because translate.google.com restricts certain types of requests to prevent service overloading. For example, if you use wget without the “-U Mozilla” parameter, you will get HTTP 404 because the service restricts responses from the default wget user agent string.

In your case, it looks like it happens that translate.google.com returns HTTP 404 if the HTTP request is included in the request. When you run wget from the command line, there is no link. When you use an audio tag inside a web page, an HTTP-Referrer is provided when requesting a translation. I just tried the following and got 404.

 wget --referer="http://foo.com" -U Mozilla -O /tmp/tts.mp3 "http://translate.google.com/translate_tts?tl=en&q=Welcome+to+our+fantastic+text+to+voice+demonstration 

However, if you take the --referer option, it works.

+4
source

The service works here (November 11th, 2011), but is limited to 100 characters. You can split the text into 100 char chunks, download the mp3 result for each fragment, and then join the fragments for the final Mp3 file.

+3
source

All Articles