Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp Folder created every time I call phonemize #147

Open
mbpictures opened this issue Mar 21, 2023 · 3 comments
Open

Temp Folder created every time I call phonemize #147

mbpictures opened this issue Mar 21, 2023 · 3 comments

Comments

@mbpictures
Copy link

mbpictures commented Mar 21, 2023

Describe the bug
I just opened my temp folder and saw, that there exist over 120.000 folders. Nearly all of them contain a libespeak-ng.dll file.

Phonemizer version
phonemizer-3.2.1
available backends: espeak-ng-1.52, segments-2.2.1
uninstalled backends: espeak-mbrola, festival

System
Windows 11 64bit
Python 3.9

To reproduce
Call the phonemize function (either the regular one or directly from the EspeakBackend).

Expected behavior
Cleaned up temp folders after each usage of the phonemizer package.

Additional context
No additional context

@mmmaat
Copy link
Collaborator

mmmaat commented Jul 12, 2023

Hi, thanks for reporting this.

Well... this seems to be a bug and that the atexit call does not work on Windows, see here for the concerned code and some comments.

We need to refactor the way the copy of the espeak library is deleted, as we have also trouble on Linux (see #153). Maybe a simple implementation of __del__ is enough? I don't remember why I did something so complicated when I implemented that few years ago...

If someone read this and want to write a fix, I would really appreciate to review your pull request!

@MiniXC
Copy link

MiniXC commented Nov 28, 2023

Hi, I encountered this as well and fixed it by creating a "Phonemizer" object which initialises the backends only once. I can work on a pull request, but it would change the API such that the usage would be as follows

from phonemizer import Phonemizer
myphonemizer = Phonemizer( 
# backend-specific args
)
# replaces phonemizer.phonemize
myphonemizer("some text")

You can see the relevant code here (no docs, tests, etc yet): https://github.com/MiniXC/phonemizer-object/blob/master/phonemizer/phonemize.py

@msalhab96
Copy link

msalhab96 commented Jan 17, 2024

@MiniXC I tested your changes, but still the change you made will not work when you do multithreading.

So as for now you either will sacrifice memory or sacrifice compute time and concurrency if it behind an API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants