desbma / GoogleSpeech

Read text using Google Translate TTS API
GNU Lesser General Public License v2.1
161 stars 37 forks source link

HTTP Error 403 #4

Closed 5LICK closed 8 years ago

5LICK commented 8 years ago

I see error when use google_speech (i used "en" and "ru" languages)

google_speech -l en "two"
Exception in thread PreloaderThread-0:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/dist-packages/google_speech/__init__.py", line 46, in run
    segment.preLoad()
  File "/usr/local/lib/python3.4/dist-packages/google_speech/__init__.py", line 182, in preLoad
    audio_data = self.download(url)
  File "/usr/local/lib/python3.4/dist-packages/google_speech/__init__.py", line 238, in download
    response.raise_for_status()
  File "/usr/local/lib/python3.4/dist-packages/requests/models.py", line 837, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://translate.google.com/translate_tts?client=t&ie=UTF-8&idx=0&total=1&textlen=3&tl=en&tk=107240%7C207805&q=two

I think problem with tk parameter in the request..

desbma commented 8 years ago

Thank you for reporting this, it seems indeed that the tk parameter has changed.

desbma commented 8 years ago

What I found out so far (note to myself): The tk parameter is now a float (xx.yy), and is a function of:

It is checked server side and lead to a 403 error if the tuple (user agent, speech, tk value) is not valid.

Fixing this is not going to be trivial, but I'll look at it more when I have some time.

desbma commented 8 years ago

Related: https://github.com/pndurette/gTTS/issues/14#issuecomment-166023782

5LICK commented 8 years ago

Thanks for answer, I will seek solution