gTTS text to speech support

Hello all,

since a short time I get the following error when using the Addon gTTS text to speech support. I already deleted and reinstalled gTTS text to speech support but the error remains. I hope I get help here.


Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you’ve discovered the add-on that is causing the problem, please report the issue on the add-on support site.
Debug info:
Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2020-11-09 20:21:07

Caught exception:
Traceback (most recent call last):
File “aqt\taskman.py”, line 87, in on_closures_pending
File “aqt\taskman.py”, line 59, in
File “aqt\sound.py”, line 238, in
File "C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525_init
.py", line 164, in _on_done
ret.result()
File “concurrent\futures_base.py”, line 432, in result
File “concurrent\futures_base.py”, line 388, in _get_result
File “concurrent\futures\thread.py”, line 57, in run
File “aqt\sound.py”, line 238, in
File "C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525_init
.py", line 160, in _play
tts.save(self._tmpfile)
File “C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525\vendor\gtts\tts.py”, line 295, in save
self.write_to_fp(f)
File “C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525\vendor\gtts\tts.py”, line 251, in write_to_fp
prepared_requests = self._prepare_requests()
File “C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525\vendor\gtts\tts.py”, line 194, in _prepare_requests
part_tk = self.token.calculate_token(part)
File “C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525\vendor\gtts_token\gtts_token.py”, line 28, in calculate_token
seed = self._get_token_key()
File “C:\Users\ingob\AppData\Roaming\Anki2\addons21\391644525\vendor\gtts_token\gtts_token.py”, line 58, in _get_token_key
raise ValueError(
ValueError: Unable to find token seed! Did https://translate.google.com change?

Many thanks, Ingo

It seems that Google has updated and switched to another way of generating speech.
This issue is currently open on GitHub. Further information you’ll find here: https://github.com/pndurette/gTTS/issues/232

There is also a workaround provided that works fine for me.

In file __init__.py I replaced line #160

tts.save(self._tmpfile)

with

  # Workaround to avoid error in save function
        count=1
        while True:
            try:
                tts.save(self._tmpfile)
                break
            except:
                print('got the issue '+str(count))
                count+=1
        
        # The following line was there before
        # tts.save(self._tmpfile)

Regards, Ingo

Thanks for posting your workaround. I’d recommend adding a limit on the count, or you could end up waiting forever if it stops working completely. You may also want to consider switching over to the AwesomeTTS add-on, as I believe it supports native Anki TTS tags now, and it is better supported.

Hi Damien,

Many thanks for the tip. I do not have any problems with it yet but I will take it into account.
I have tried the AwesomeTTS addon in the past and was not so happy with it. I hope there there will be a fix soon.

Regards, Ingo

This workaround doesn’t work for me. I also removed and installed again add-on but no success.

This topic is closed:

I found something like this in Arch repo:
https://aur.archlinux.org/packages/python-gtts-token
should I install it?