bootphon / phonemizer

Simple text to phones converter for multiple languages

Home Page:https://bootphon.github.io/phonemizer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Temp Folder created every time I call phonemize

mbpictures opened this issue · comments

commented

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

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!

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

@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