0

the code below saves the audio file from google translate text to speech engine. It used to work (in 2014) but now the robot/human verification picture-text stops it. Is there a way to solve it?

import urllib2

url = "http://translate.google.com/translate_tts?tl=en&q=hello"
request = urlib2.Request(url)
request.add_header('User-agent','Mozilla/5.0')
opener = urllib2.build_opener()
f = open('out.mp3',"wb")
f.write(opener.open(request).read())

When I enter the link directly in the internet browser, I face the picture verification. One time verification doesn't bring it anymore. But still the python code brings up error message

raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) 
urllib2.HTTPError: HTTP Error 503: Service Unavailable

http error 302 was also there before.

Amin
  • 437
  • 2
  • 4
  • 17
  • maybe see this answer http://stackoverflow.com/questions/9893175/google-text-to-speech-api/31791632#31791632 – Joran Beasley Nov 23 '15 at 20:05
  • @Amin you found any solution? i am facing same problem.. http://stackoverflow.com/questions/35902115/urllib2-httperror-http-error-503-in-bs4-python – Mehul Parmar Mar 10 '16 at 13:16
  • @Mahul. I used other tts engine than google. I couldn't resolve the problwm with google. I checked your question and you're facing the problwm with google scholar. I am afraid my solution won't help you. good luck. – Amin Mar 10 '16 at 13:26

0 Answers0