6

I have this URL: http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=Hello+world When I put it to the address bar in a browser and hit enter, I get mp3 file with synthesized speech saying "Hello world". Everything is correct.

But now I have a link in HTML that redirects to this URL, like this:

<a href="http://translate.google.com/translate_tts?ie=utf-8&tl=en&q=Hello+world">Link</a>

When I click this link, I don't get a file but an error (simple QuickTime logo). Could anyone explain me why is it so and how can I solve my problem?

pb2q
  • 58,613
  • 19
  • 146
  • 147
Piotr Chojnacki
  • 6,837
  • 5
  • 34
  • 65

1 Answers1

6

The explanation is that Google restricts the usage of this service: according to this StackOverflow answer, Google returns a 404 error if the HTTP request contains a Referer header other than an empty string.

When you type the URL in the address bar, it's ok because no Referer URL is transmitted to Google. When you click on a hyperlink, you have a referer and Google blocks your request.

NB: I tested your URL (see here), and it worked. I suspect that it was only because I have tried before by typing the URL in my address bar, and the resource was still in my browser cache or in my audio plugin (VLC) cache.

NB2: See here for a workaround.

Community
  • 1
  • 1
olivierlemasle
  • 1,219
  • 16
  • 31
  • What browser are you using? When I try to open your link with firefox, I only get an empty QuickTime logo and when I open it with Opera, I get an error stating that such page doesn't exist. Strange thing, because when I hit enter while having the same address specified in address bar, I'm getting a proper file. – Piotr Chojnacki Oct 14 '12 at 16:35
  • I'm using Firefox 16 and the sound is played with VLC plugin. I tried with Google Chrome (with default sound player) and it works too... It seems to be an issue with Apple Quicktime Player plugin. What browser are YOU using? – olivierlemasle Oct 14 '12 at 16:39
  • I'm using Firefox and Opera. I tried on other PC and result is the same. – Piotr Chojnacki Oct 14 '12 at 16:48