0

I had no problems with gTTS before:

import gtts

stop = ('My voice!')
tts = gtts.gTTS(text=stop, lang='en')
tts.save("D:\\path\\Voice.mp3")

but suddenly there was an error:

Traceback (most recent call last):
  File "D:/folder1/project/prog1.py", line 6, in <module>
    tts.save("D:\\project\\Voice.mp3")
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\gtts-1.1.4-py3.5.egg\gtts\tts.py", line 94, in save
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\gtts-1.1.4-py3.5.egg\gtts\tts.py", line 118, in write_to_fp
  File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests-2.9.1-py3.5.egg\requests\models.py", line 840, 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?q=SAY+YES%21&tk=834753.692152&tl=en&total=1&client=t&idx=0&ie=UTF-8&textlen=8

not really understand, how to figure out with this problem

I have upgraded gTTS

pip install gTTS --upgrade gTTS

but got same error.

EDIT : ---------------------------------------------------------------------------

solution source: https://github.com/pndurette/gTTS/issues/32

same in my case:

C:\Users\User\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\gtts

in tts.py

line 105

and change client=t to 'client' : 'tw-ob',

1 Answers1

0

I installed the gtts package and was able to replicate this issue. In this case, the Google Translate URL used by the gtts package no longer works (it returns a 403 HTTP error). This should probably be reported as a bug to the gtts package maintainers as it looks like Google’s Text to Speech API has changed (or broke).

Edit: This issue has already been reported.

Anthony Geoghegan
  • 11,533
  • 5
  • 49
  • 56