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

RuntimeError: espeak not installed on your system #163

Open
rumbleFTW opened this issue Jan 2, 2024 · 13 comments
Open

RuntimeError: espeak not installed on your system #163

rumbleFTW opened this issue Jan 2, 2024 · 13 comments

Comments

@rumbleFTW
Copy link

rumbleFTW commented Jan 2, 2024

I am facing this error when I try to initialize the phonemizer backend:
RuntimeError: espeak not installed on your system

I already have installed espeak-ng using pacman -S espeak-ng and set the path PHONEMIZER_ESPEAK_LIBRARY to my espeak binary. Any idea on how to fix this?

Details:
OS: Arch linux.
Python version: 3.8.18
espeak-ng version: 1.51.1

@sway4em
Copy link

sway4em commented Jan 4, 2024

I'm having the same issue

@rumbleFTW
Copy link
Author

@sway4em Could you please mention your Operating system? I think this problem can be solved in MacOS (#159) and Windows (#44).

@sway4em
Copy link

sway4em commented Jan 4, 2024

@rumbleFTW I'm on MacOS

@rumbleFTW
Copy link
Author

Please check #159 for the solution for MacOS.

@sbinnee
Copy link

sbinnee commented Jan 4, 2024

I just had the same issue. I did some digging. I think it has to do with how I made virtual environment at least for me. I used conda just as normally as I do. Then I called ctypes.cdll.LoadLibrary('libespeak-ng.so.1'), which is called when EspeakAPI is initialized.

Note that I installed espeak-ng from Arch repo just like @rumbleFTW did.

Here is the output

import ctypes
ctypes.cdll.LoadLibrary('libespeak-ng.so.1')

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[6], line 1
----> 1 ctypes.cdll.LoadLibrary('libespeak-ng.so.1')

File ~/miniconda3/envs/tts/lib/python3.10/ctypes/__init__.py:452, in LibraryLoader.LoadLibrary(self, name)
    451 def LoadLibrary(self, name):
--> 452     return self._dlltype(name)

File ~/miniconda3/envs/tts/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 self._FuncPtr = _FuncPtr
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:
    376     self._handle = handle

OSError: /home/seongbin/miniconda3/envs/tts/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/libespeak-ng.so.1)

It's looking for libs in relative path. I know that conda redefines lib path as well as bin path. So the solutions I am thinking are 1. install espeak-ng using conda so that conda can places libs as well as bins under new path or 2. do not use conda, use something else like venv.

I will put updates when I tried them. But I won't have time this weekend. So if someone wants to try, please do and it would be appreciated if someone can verify them.

@rumbleFTW
Copy link
Author

@sbinnee You are probably correct, since I am trying to do this in a conda env as well, and might be because of the way conda handles the libs. However the espeak-ng package is not present in the conda repositories as far as I know. I tried the second method that you suggested i.e. use venv for the environment, and it worked flawlessly. So it is indeed because of the conda env. Although this solves the issue, my workflow is really dependent on conda, so I still need to figure out how to make it work in a conda env.

@mmmaat
Copy link
Collaborator

mmmaat commented Jan 8, 2024

Hi, did you tried that (from docs):

conda env config vars set PHONEMIZER_ESPEAK_LIBRARY="/somewhere/to/libespeak-ng.so"

?

@rumbleFTW
Copy link
Author

Just tried. Didn't work for me. Can someone else like @sbinnee test out if it solves the issue on their system?

@scutcsq
Copy link

scutcsq commented Jan 9, 2024

I met the same problem. My platform is Linux. Besides, I don't know where the 'libespeak-ng.so' is located

@Teravus
Copy link

Teravus commented Jan 15, 2024

Yeah, this is definitely still a problem for windows users.
Tried:

from phonemizer.backend.espeak.wrapper import EspeakWrapper
_ESPEAK_LIBRARY = r'C:\Program Files\eSpeak NG\libespeak-ng.dll'
EspeakWrapper.set_library(_ESPEAK_LIBRARY)

Traceback (most recent call last):
File "E:\vits2\vits2\lib\site-packages\joblib\externals\loky\process_executor.py", line 426, in _process_worker
call_item = call_queue.get(block=True, timeout=timeout)
File "F:\Python310\lib\multiprocessing\queues.py", line 122, in get
return _ForkingPickler.loads(res)
File "E:\vits2\vits2\lib\site-packages\phonemizer\backend\espeak\wrapper.py", line 92, in setstate
self.init()
File "E:\vits2\vits2\lib\site-packages\phonemizer\backend\espeak\wrapper.py", line 60, in init
self._espeak = EspeakAPI(self.library())
File "E:\vits2\vits2\lib\site-packages\phonemizer\backend\espeak\wrapper.py", line 141, in library
raise RuntimeError( # pragma: nocover
RuntimeError: PHONEMIZER_ESPEAK_LIBRARY="C:\Program Files\eSpeak NG\libespeak-ng.dll" is not a readable file

It's there. It's the 64 bit version. I don't know what it wants.

I edited wrapper.py to see what would happen and it printed out the actual error;
RuntimeError: failed to load espeak library: Could not find module 'E:\vits2\datasets\ljs_base\prepare"C:\Program Files\eSpeak NG\libespeak-ng.dll"' (or one of its dependencies). Try using the full path with constructor syntax.

Why the heck it is trying to prepend the current directory of the running script?

@Teravus
Copy link

Teravus commented Jan 15, 2024

image

This is the only thing that worked for me. Hacking the library.

@lauraBoll
Copy link

I have the same problem in a VM with Linux Ubuntu 22.04.4 LTS (x86-64)

Even though the model worked fine on a local machine with windows, when passing the path to the espeak-ng library according to this installation guide https://bootphon.github.io/phonemizer/install.html , I could not make it work in a VM under Ubuntu 22.04.4 LTS x86-64. When running my script to transcribe phonemes via wav2vec2phoneme, I got the following message

Traceback (most recent call last):
File "/dialrec/phoneme_transcription/phoneme_recognizers/transcribe.py", line 50, in
phoneme_recognizer = Wav2Vec2Phoneme()
File "/dialrec/phoneme_transcription/phoneme_recognizers/wav2vec2phoneme.py", line 24, in init
self.processor = Wav2Vec2Processor.from_pretrained("facebook/wav2vec2-xlsr-53-espeak-cv-ft")
File "/usr/local/lib/python3.10/site-packages/transformers/models/wav2vec2/processing_wav2vec2.py", line 52, in from_pretrained
return super().from_pretrained(pretrained_model_name_or_path, **kwargs)
File "/usr/local/lib/python3.10/site-packages/transformers/processing_utils.py", line 465, in from_pretrained
args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
File "/usr/local/lib/python3.10/site-packages/transformers/processing_utils.py", line 511, in _get_arguments_from_pretrained
args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
File "/usr/local/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py", line 837, in from_pretrained
return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
File "/usr/local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2086, in from_pretrained
return cls._from_pretrained(
File "/usr/local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2325, in _from_pretrained
tokenizer = cls(*init_inputs, **init_kwargs)
File "/usr/local/lib/python3.10/site-packages/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py", line 153, in init
self.init_backend(self.phonemizer_lang)
File "/usr/local/lib/python3.10/site-packages/transformers/models/wav2vec2_phoneme/tokenization_wav2vec2_phoneme.py", line 202, in init_backend
self.backend = BACKENDS[self.phonemizer_backend](phonemizer_lang, language_switch="remove-flags")
File "/usr/local/lib/python3.10/site-packages/phonemizer/backend/espeak/espeak.py", line 45, in init
super().init(
File "/usr/local/lib/python3.10/site-packages/phonemizer/backend/espeak/base.py", line 39, in init
super().init(
File "/usr/local/lib/python3.10/site-packages/phonemizer/backend/base.py", line 77, in init
raise RuntimeError( # pragma: nocover
RuntimeError: espeak not installed on your system

For installing espeak, I followed these steps:

  1. apt-get install espeak-ng
  2. pip3 install phonemizer
  3. pip3 install espeakng (also tried pip3 install py-espeak-ng)

Espeak is definitely installed under /usr/lib/x86_64-linux-gnu/libespeak-ng.so.1 and /usr/bin/espeak-ng.

I tried the following:

  • without additional steps
  • Setting the environmental variable PHONEMIZER_ESPEAK_LIBRARY='/usr/lib/x86_64-linux-gnu/libespeak-ng.so.1' and PHONEMIZER_ESPEAK_PATH='/usr/bin/espeak-ng'.
  • Setting the environmental variable directly in the script with
    os.environ['PHONEMIZER_ESPEAK_LIBRARY'] = '/usr/lib/x86_64-linux-gnu/libespeak-ng.so.1'
    os.environ['PHONEMIZER_ESPEAK_PATH'] = '/usr/bin/espeak-ng'

I would appreciate any help. Thanks in advance.

@JeffChien
Copy link

Hi, did you tried that (from docs):

conda env config vars set PHONEMIZER_ESPEAK_LIBRARY="/somewhere/to/libespeak-ng.so"

?

I had the same issue on my M1 pro macbook, this environment worked. I changed it to somewhere like
export PHONEMIZER_ESPEAK_LIBRARY=/opt/homebrew/opt/espeak-ng/lib/libespeak-ng.dylib

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

No branches or pull requests

8 participants