Anki play method blocks removing generated files

Hello there,

I implemented some functionality on my addon and I need to generate temporary files to write an TTS audio and then use play() method from aqt.sound to play it. But when I try to use os.remove() it raises an exception saying that the file is being used by another proccess. How to deal with that?

You have your source code available somewhere? Could you post a full stack trace? I don’t suppose you’re on Windows?

The code is available at GitHub - warleysr/ankipa: Anki addon for Pronunciation Assessment

In the init.py I try to remove the generated temp file. Yes, I’m using Windows.

Perhaps try using a non-deprecated function? It’s unclear what happens to the file handle when you call play(). It uses some global state in the av_player object in sound.py. Perhaps they aren’t being closed.

Why don’t you write a quick CI workflow so those of us not on Windows might be able to reproduce your issue?

Sorry, I don’t know how to do that. If you don’t mind to explain, I could try.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.