Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google TTS not working #64

Open
jchtt opened this issue Dec 28, 2015 · 3 comments
Open

Google TTS not working #64

jchtt opened this issue Dec 28, 2015 · 3 comments

Comments

@jchtt
Copy link

jchtt commented Dec 28, 2015

If I check Baidu Translate for TTS, everything works as expected, i.e. the sound file gets downloaded and properly linked. However, if I check Google Mandarin TTS, no sound file gets generated when I add a card.

This is on Archlinux, Anki Version 2.0.33, Qt 4.8.7, PyQt 4.11.4, Chinese-support-addon 0.10.10.

@multani
Copy link

multani commented Jan 3, 2016

When requesting the TTS file from Google, the urllib2.urlopen() call from google_tts.py module throws a 503 error which is silently caught earlier, with the following:

$ curl  -vv 'http://translate.google.com/translate_tts?client=t&q=%E6%9B%BE&tl=zh'  -H 'User-Agent: Anki'
*   Trying 173.194.116.96...
* Connected to translate.google.com (173.194.116.96) port 80 (#0)
> GET /translate_tts?client=t&q=%E6%9B%BE&tl=zh HTTP/1.1
> Host: translate.google.com
> User-Agent: Anki
> Accept: */*
> 
< HTTP/1.1 503 Service Unavailable
< Date: Sun, 03 Jan 2016 21:57:04 GMT
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Content-Type: text/html
< Server: HTTP server (unknown)
< Content-Length: 1772
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>http://www.google.com/</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById('captcha');if(e){e.focus();}">
<div style="max-width:400px;">
 <hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>


  <div style="font-size:13px;">
   Our systems have detected unusual traffic from your computer network.  Please try your request again later.  <a href="#" onclick="document.getElementById('infoDiv0').style.display='block';">Why did this happen?</a><br><br>
   <div id="infoDiv0" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
    This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may see this page if you are using advanced terms that robots are known to use, or sending requests very quickly.
   </div><br>

 IP address: xxx.xxx.xxx.xxx<br>Time: 2016-01-03T21:57:04Z<br>URL: http://www.google.com/<br>
 </div>
</div>
</body>
</html>
* Connection #0 to host translate.google.com left intact

Note that I haven't been doing any particular abuse of Google Translate from here, and using the Google Translate website directly plays the right sound. Apparently, after looking at the URL used by the website, Anki is missing a tk URL parameter, which allows the query to succeed.

@multani
Copy link

multani commented Jan 3, 2016

And this tk parameter seems to be computed differently for each different input...

@p2635
Copy link

p2635 commented Aug 6, 2018

I have a field for Sound - Cantonese and it's not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants