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

espeak installed but unable to found by phnemizer #117

Closed
lucasjinreal opened this issue Mar 30, 2022 · 21 comments
Closed

espeak installed but unable to found by phnemizer #117

lucasjinreal opened this issue Mar 30, 2022 · 21 comments
Labels

Comments

@lucasjinreal
Copy link

/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?

@mmmaat
Copy link
Collaborator

mmmaat commented Mar 30, 2022

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).

@lucasjinreal
Copy link
Author

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.

@xihalameilin
Copy link

how can you solve ? @jinfagang

@mmmaat mmmaat added the macos label Nov 25, 2022
@amallecourt
Copy link

amallecourt commented Dec 27, 2022

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

@newtondotcom
Copy link

still doesn't work :(
always the same error : espeak not installed on your system, even after following your steps

@amallecourt
Copy link

Sorry, there was a typo mistake in my answer, try again please

@lukasschmit
Copy link

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?

@amallecourt
Copy link

No, I don't think so.
Try to look in phenomizer.backend.espeak.wrapper.py if you satisfy all conditions

@lukasschmit
Copy link

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

@TythonLee
Copy link

In my ubuntu environment, set the path works: export PHONEMIZER_ESPEAK_LIBRARY=/usr/bin/espeak-ng

@SkyViz
Copy link

SkyViz commented Dec 19, 2023

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

@TythonLee
Copy link

TythonLee commented Dec 19, 2023 via email

@vmirnv
Copy link

vmirnv commented Dec 19, 2023

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>

@iackov
Copy link

iackov commented Mar 5, 2024

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)

@TythonLee
Copy link

TythonLee commented Mar 5, 2024 via email

@DrBrule
Copy link

DrBrule commented May 26, 2024

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'))

@TythonLee
Copy link

TythonLee commented May 26, 2024 via email

@jmainzy
Copy link

jmainzy commented Sep 17, 2024

I solved this problem on my M1 Mac for running code in Jupyter Notebook:

1. Install arm64 brew:

This was it for me. This whole time I was using x86_64 homebrew and installing the arm64 version fixed it. When I switched to arm64, the path changed from /usr/local/Cellar to /opt/homebrew/Cellar

Note: A clearer way to debug this would have been if the library loading function prints out the actual error instead of just "espeak not installed on your system". You can print it out in /phonemizer/backend/espeak/base.py inside of the is_available function:

@classmethod
def is_available(cls) -> bool:
     try:
          EspeakWrapper()
     except RuntimeError as e:  # pragma: nocover
          print('espeak backend is not available: ' + str(e))
          return False
      return True

Then it'll show exactly why the library fails to load. For me, it was refusing to load the x86_64 version and wanted an arm64 version. This is what @vmirnv shows with the sanity checks above in step 3.

@TythonLee
Copy link

TythonLee commented Sep 17, 2024 via email

@philippollmann
Copy link

philippollmann commented Jan 10, 2025

It also worked for me to define the path to the espeak library as follows (macos with m1):

from phonemizer import phonemize
from phonemizer.backend.espeak.wrapper import EspeakWrapper

EspeakWrapper.set_library('/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib')

german_text = "Guten Tag"
ipa_transcription = phonemize(german_text, language='de', backend='espeak')

@TythonLee
Copy link

TythonLee commented Jan 10, 2025 via email

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

No branches or pull requests