Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

HTTP Error 403 #4

Closed
5LICK opened this issue Dec 18, 2015 · 4 comments
Closed

HTTP Error 403 #4

5LICK opened this issue Dec 18, 2015 · 4 comments

Comments

@5LICK
Copy link

5LICK commented Dec 18, 2015

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
Copy link
Owner

desbma commented Dec 18, 2015

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

@desbma
Copy link
Owner

desbma commented Dec 18, 2015

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

  • the User Agent HTTP header
  • the "speech" string
  • something else I have not found out, maybe randomness (two subsequent sound generations throught the translate site for the same text, do not lead to the same sound URL)

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
Copy link
Owner

desbma commented Dec 20, 2015

Related: pndurette/gTTS#14 (comment)

@5LICK
Copy link
Author

5LICK commented Dec 20, 2015

Thanks for answer, I will seek solution

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

No branches or pull requests

2 participants