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

Crash every second time fields are automatically filled due to audio #194

Open
FancyFoxPerson opened this issue Oct 2, 2021 · 0 comments

Comments

@FancyFoxPerson
Copy link

FancyFoxPerson commented Oct 2, 2021

Edit: The issue has something to do with the way the Audio field is filled in automatically. If there is no valid audio field, the crash won't happen.

Describe the bug
When entering something in the "Hanzi" field of the note type "Chinese (Advanced)", it works the first time, but the second time the add-on will crash and give the following error:

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, repeat 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-ons section of our support site. 
Debug info:
Anki 2.1.48 (fb07bad3) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-10-01 17:02:34

Caught exception:
Traceback (most recent call last):
  File "aqt\webview.py", line 41, in cmd
  File "aqt\webview.py", line 142, in _onCmd
  File "aqt\webview.py", line 595, in _onBridgeCmd
  File "aqt\editor.py", line 380, in onBridgeCmd
  File "aqt\hooks_gen.py", line 1986, in __call__
  File "anki\hooks.py", line 45, in runFilter
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\edit.py", line 74, in onFocusLost
    if update_fields(note, field, allFields):
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\behavior.py", line 270, in update_fields
    fill_sound(hanzi, copy)
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\behavior.py", line 169, in fill_sound
    s = sound(hanzi, config['speech'])
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\sound.py", line 51, in sound
    return '[sound:%s]' % AudioDownloader(hanzi, source).download()
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\tts.py", line 50, in download
    self.func()
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\tts.py", line 56, in get_google
    tts.save(self.path)
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\lib\gtts\tts.py", line 243, in save
    self.write_to_fp(f)
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\lib\gtts\tts.py", line 183, in write_to_fp
    part_tk = self.token.calculate_token(part)
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\lib\gtts_token\gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "C:\Users\thiba\AppData\Roaming\Anki2\addons21\1128979221\lib\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?

After that, the only way to continue using the add-on is to restart Anki.

To Reproduce
Steps to reproduce the behavior:
Add a note with "Chinese (Advanced)", enter Chinese characters into field "Hanzi", press TAB. Repeat.

Expected behavior
A proper automatic filling of the appropriate fields, like it does half the time.

Screenshots
Not applicable

Specs (please complete the following information):

  • OS: Windows 10
  • Anki Version 2.1.48
  • Chinese Support Version: v0.14.2

Additional context
The config file is the default one. I had this addon a long time ago and the only thing I have updated is the addon itself. Maybe there is something wrong with the note type? Can I bring it back to the default? Does it matter?

@FancyFoxPerson FancyFoxPerson changed the title Crash with normal use Crash every second time fields are automatically filled Oct 2, 2021
@FancyFoxPerson FancyFoxPerson changed the title Crash every second time fields are automatically filled Crash every second time fields are automatically filled due to audio Oct 2, 2021
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

1 participant