Toocanzs/anki-voicevox

Error on startup

Closed this issue · 13 comments

I get the same error on startup in either Windows or Linux. It happens even when this is the only addon active.

I tried seeing if this was ignorable, but that led to a crash.

Anki 24.06.3 (d678e393)  (ao)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1
Platform: Windows-10-10.0.19045

Traceback (most recent call last):
  File "aqt.progress", line 119, in handler
  File "aqt.main", line 219, in on_window_init
  File "aqt.main", line 266, in setupProfileAfterWebviewsLoaded
  File "aqt.main", line 318, in setupProfile
  File "aqt.main", line 530, in loadProfile
  File "_aqt.hooks", line 4107, in __call__
  File "anki.hooks", line 34, in runHook
  File "C:\Users\jack\AppData\Roaming\Anki2\addons21\366960193\ffmpeg.py", line 46, in GetFFmpegIfNotExist
    progress_win.show()
AttributeError: 'NoneType' object has no attribute 'show'

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
VOICEVOX Japanese Text To Speech Audio Generator ['366960193', 2024-04-09T15:07, 'None', '']

===IDs of active AnkiWeb add-ons===
366960193

===Add-ons (inactive)===
SNIPPED

I've pushed an update that should fix this issue, but let me know if it's still happening or if any other issues pop up. Thanks.

This seems to have fixed this issue with startup, thanks. I still get have another issue where when I right click on a card and select Generate VOICEVOX Audio then Anki stops responding, but that's a separate issue so I'll close this one.

image

Later today I may try to trace/fix this new issue myself (if you don't fix it by then haha), I really like this project so I want to get it working.

Yea please make another issue for that. Doesn't seem to happen on my end.

I assume you have voicevox running in the background? Anki will freeze for a moment and display an error after a moment if voicevox isn't open for me, but perhaps there's no timeout on certain platforms?

Actually looking at requests.get and requests.post it seems like there is no timeout by default, but on windows it automatically returns an error after 5 seconds for me.

I don't know if that's exactly what you're running into but it shouldn't be relying on an OS level timeout anyway. e85c6f9 might fix this for you. I also pushed an update to ankiweb, so try updating that and see if you get the error.

Alright, I did some more testing and I think the issue is still related to this bug. I actually got the addon working on both windows and linux, but something seems broken in the first launch/initial setup.

If I launch without the ffmpeg executable cached yet, then a "Checking" dialog box appears and never goes away. It's the only dialog which shows up too. Normal methods of closing the window don't work and I have to force end in task manager on windows and pkill -9 anki on linux.
checking

It does seem to actually download ffmpeg though. I think when I first tried it on windows I was impatient and killed it before ffmpeg finished downloading, which made it break when I tried to use it. When I waited longer before killing it on windows it worked fine the next time I started it.

So the issue seems to be that something weird is happening with the dialogs when you start without a cached ffmpeg. I believe the reason it crashed anki when I tried to use it before is that I was somehow getting to the browser window without having ffmpeg cached at all. If you can't reproduce this I can do more debugging myself as well.

What exactly are the steps to reproduce this?
Is it just: Startup the addon with no ffmpeg.exe in the addon folder?

If so this doesn't happen on my end on windows

Yes I just double checked, for me this happens consistently on both win10 and NixOS if I

  1. Start with a working installation (and no other addons installed)
  2. Go into the addons21/366960193 folder and delete the cached ffmpeg binary
  3. Start anki again

Then the ffmpeg binary does get downloaded again, but an unclosable "Checking" dialog hangs there

I've messed around a little with with Anki Addon programming before so I'll see if I can narrow down what exactly is happening and get back to you. I feel like it's probably not something insanely specific to my setup since it's on two totally different operating systems w/ no other addons, but that's always a possibility haha

Yea please do look into it if you're willing to since I'm unable to reproduce.
It could be that exact version of Anki triggers the issue on both linux and windows, assuming you share the same version on both.

I'm on Anki 23.10. I'm not aware of anyone else hitting this issue, but perhaps they just haven't reported it.

I'm on Anki 24.06.3, so yeah maybe this is an API change. I found the exact line that's causing the Checking, If I make this patch to ffmpeg.py then it silently but correctly downloads ffmpeg in the background and starts normally.

image

Oh yep I just updated and I reproduced this issue.

I'm not sure what the new API for progress has become but I'm thinking I should just remove the progress bar.

I have been bit by API changes like this multiple times now and I think my only defense against it is lowering the surface area of the code, or firefighting every Anki API change... I'm really not a fan of having a bunch of Anki version checks for different APIs

Ok try the latest update

Works perfectly! Thanks so much for the prompt responses and for making this tool in the first place.

No problem.
There's a good chance people have been hitting this issue and just fixing it by restarting without reporting the issue, so thanks for taking the time to report it.