espeak installed but unable to found by phnemizer
lucasjinreal opened this issue · comments
/phonemizer/backend/base.py", line 73, in __init__
raise RuntimeError( # pragma: nocover
RuntimeError: espeak not installed on your system
(base) jintn@jintndeMBP ~/d/c/a/b/t/v/nix-tts> brew install espeak
Warning: espeak 1.48.04_1 is already installed and up-to-date.
To reinstall 1.48.04_1, run:
Any idea?
Maybe espeak
has been installed by brew into a non-standard location?
If you know where your espeak.dylib
file has been installed, just do this before using phonemizer:
export PHONEMIZER_ESPEAK_LIBRARY=/path/to/espeak.dylib
phonemize "whatever params you need"
On Linux you can locate the path to that library with ldd $(which espeak) | grep espeak
, the equivalent command on macos should be otool -L $(which espeak) | grep espeak
(I'm not sure I don't have a mac).
on macOS, seems ctypes unable to find it. I installed using brew, and it was inside /opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib
, solved it already.
how can you solve ? @jinfagang
Another reason that can provoque this error on Mac M1/M2, is the architecture incompatibility (arm64 vs x86_64). Here, the phenomizer
libraire needs an espeak
installation from the x86_64 architecture. So if you are on arm64, you should first install homebrew
for x86_64, and then use this version to install espeak
. And it'll work.
For the details:
- install homebrew for x86_64 with Rosetta
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- install espeak for x86_64
arch -x86_64 /usr/local/bin/brew install espeak
- create the environment variable to redirect to the right file
export PHONEMIZER_ESPEAK_LIBRARY=/usr/local/Cellar/espeak/1.48.04_1/lib/libespeak.dylib
still doesn't work :(
always the same error : espeak not installed on your system, even after following your steps
Sorry, there was a typo mistake in my answer, try again please
Hi, I'm having this issue on a new M2 mbp. I tried running your commands @amallecourt but still get the same "espeak not installed" error. Do you have to run python with some architecture flag?
No, I don't think so.
Try to look in phenomizer.backend.espeak.wrapper.py if you satisfy all conditions
figured it out—for my brew installation on my m2 the path is PHONEMIZER_ESPEAK_LIBRARY=/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib
for anyone else who stumbles into this haha
In my ubuntu environment, set the path works: export PHONEMIZER_ESPEAK_LIBRARY=/usr/bin/espeak-ng
figured it out—for my brew installation on my m2 the path is
PHONEMIZER_ESPEAK_LIBRARY=/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib
for anyone else who stumbles into this haha
I tried the same, but its not working for me. When I use terminal and check if I had set the variable correctly? it shows me correct results.
yajvikani@Skys-MacBook ~ % echo $PHONEMIZER_ESPEAK_LIBRARY
/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib
Also, within terminal when I try espeak hello, it works. but it does not work when I use it in a python code:
from phonemizer import phonemize
phonemize("Hello", language='en-us', backend='espeak')
RuntimeError: espeak not installed on your system
I solved this problem on my M1 Mac for running code in Jupyter Notebook:
1. Install arm64 brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
brew install espeak
2. Run export before Jupyter:
export PHONEMIZER_ESPEAK_LIBRARY=/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib
jupyter notebook --no-browser
3. It should work now, but to be 100% sure, here's some additional code:
import os
import pathlib
print(pathlib.Path(os.environ['PHONEMIZER_ESPEAK_LIBRARY']).resolve())
# Output: PosixPath('/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib')
import ctypes
print(ctypes.cdll.LoadLibrary('/usr/local/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib'))
# Output: <CDLL '/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib', handle 89a128f0 at 0x10b42ccd0>
My Solution for Windows:
from phonemizer.backend.espeak.wrapper import EspeakWrapper
EspeakWrapper.set_library('C:\Program Files\eSpeak NG\libespeak-ng.dll')
eSpeak NG - Installed from official site (msi)
I solved this problem on my M1 Mac for running code in Jupyter Notebook:
Cheers for that! I just spent hours trying to get this working, this process was helpful. Ensuring that brew is installing the ARM64 version of espeak (and removing any conflicting versions from both /usr/local/bin and /opt/homebrew/... finally got it functioning for me. The ctypes sanity check pointed me in the proper direction.
It seems that homebrew defaults to the x86_64 version for some reason, and that conflicts with phonemizer.
However : print(ctypes.cdll.LoadLibrary('/usr/local/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib'))
should be
print(ctypes.cdll.LoadLibrary('/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.1.1.48.dylib'))