bootphon / phonemizer

Simple text to phones converter for multiple languages
https://bootphon.github.io/phonemizer/
GNU General Public License v3.0
1.19k stars 166 forks source link

RuntimeError: espeak not installed on your system #44

Open PasaOpasen opened 4 years ago

PasaOpasen commented 4 years ago

How to solve RuntimeError: espeak not installed on your system on Windows without using Linux in Windows?

mmmaat commented 4 years ago

You need to install espeak, or better, espeak-ng : https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md#windows

PasaOpasen commented 4 years ago

Yes, I did it and can open and use espeak application, but phonemizer raises that error still

mmmaat commented 4 years ago

Ok, so I suppose espeak-ng is not in your PATH. But phonemizer provides an alternative way to specify the path to espeak: you can setup the environment variable PHONEMIZER_ESPEAK_PATH with the absolute path to espeak (see https://github.com/bootphon/phonemizer/blob/master/phonemizer/backend/espeak.py#L62).

PasaOpasen commented 4 years ago

The path to espeak is the path to folder with TTSApp.exe, sure?

After creating this path I have an error:

PHONEMIZER_ESPEAK_PATH=C:\Program Files (x86)\eSpeak is not an executable file

Which path should I use? To which file?

mmmaat commented 4 years ago

I don't have Windows so I cannot really help you with hands on... It has already been used on Windows and you are the first one to report such an issue. The PHONEMIZER_ESPEAK_PATH must be an absolute path to the .exe file, along with the .exe extension.

Maybe PHONEMIZER_ESPEAK_PATH=C:\Program Files (x86)\eSpeak.exe will work? If you have such a file... The good file must be an executable one, usable from command line (not a GUI one).

You can also try this one: http://sourceforge.net/projects/espeak/files/espeak/espeak-1.48/setup_espeak-1.48.04.exe

PasaOpasen commented 4 years ago

Very good! There was the file C:\Program Files (x86)\eSpeak\command_line\espeak.exe and I did assign it to PHONEMIZER_ESPEAK_PATH. Now it works!

sujithvoona commented 3 years ago

Hey @PasaOpasen, before setting the environment variable path as PHONEMIZER_ESPEAK_PATH = C:\Program Files (x86)\eSpeak\command_line\espeak.exe did you store espeak.py file at any specific place.

Did the error got cleared after placing this espeak.py at a certain place and you set the environment variable path or you had nothing to do with the espeak.py file and set the environment variable "PHONEMIZER_ESPEAK_PATH"

I created a new environment variable PHONEMIZER_ESPEAK_PATH and I gave the path same as you C:\Program Files (x86)\eSpeak\command_line\espeak.exe. I am still facing the error.

Please help.

danthemango commented 3 years ago

That's because you're trying to add the path to the .exe file, you need to add the directory instead to the PATH variable: "C:\Program Files (x86)\eSpeak\command_line"

richardfoltin commented 2 years ago

The variable name is changed to PHONEMIZER_ESPEAK_LIBRARY and it refers to the .dll now: PHONEMIZER_ESPEAK_LIBRARY="c:\Program Files\eSpeak NG\libespeak-ng.dll"

cantabile-kwok commented 2 years ago

The variable name is changed to PHONEMIZER_ESPEAK_LIBRARY and it refers to the .dll now: PHONEMIZER_ESPEAK_LIBRARY="c:\Program Files\eSpeak NG\libespeak-ng.dll"

This worked very well and saved me a headache, thanks!

wukongsleeping commented 2 years ago

注意是PHONEMIZER_ESPEAK_LIBRARY和PHONEMIZER_ESPEAK_PATH 1.PHONEMIZER_ESPEAK_LIBRARY="c:\Program Files\eSpeak NG\libespeak-ng.dll" 2.PHONEMIZER_ESPEAK_PATH =“c:\Program Files\eSpeak NG”

TheKOG commented 2 years ago

注意是PHONEMIZER_ESPEAK_LIBRARY和PHONEMIZER_ESPEAK_PATH 1.PHONEMIZER_ESPEAK_LIBRARY="c:\Program Files\eSpeak NG\libespeak-ng.dll" 2.PHONEMIZER_ESPEAK_PATH =“c:\Program Files\eSpeak NG”

finally it works!

avst65t commented 1 year ago

1.PHONEMIZER_ESPEAK_LIBRARY = C:\Program Files\eSpeak NG\libespeak-ng.dll 2.PHONEMIZER_ESPEAK_PATH = C:\Program Files\eSpeak NG

click new and add these variables to your system variables in environment variables it will work

djpelu commented 1 year ago

i did this but it's still not working T_T is there maybe some detail that i'm missing? Do I need to install espeak in python or something. i'm going crazy

mmmaat commented 1 year ago

Hi, I'm not a Windows expert so I can't really help you... But. Are you sure the "C:\Program Files\eSpeak NG\libespeak-ng.dll" you provided actually is an existing file?

Another solution: Use the docker image: https://bootphon.github.io/phonemizer/install.html#docker-image. Install docker on your machine, then install the docker image of the phonemizer.

Another solution: Use Windows subsystem for Linux (https://learn.microsoft.com/en-us/windows/wsl/install)

djpelu commented 1 year ago

thanks for the fast answer, the file actually exists, but it is in Program Files (x86) so i changed the path. However it doesn't come up when i look for it as a directory, could this be the problem? thanks, i'm really not an expert

mmmaat commented 1 year ago

Ok... so it MUST BE the exact and absolute path to the libespeak-ng.dll file you installed with eSpeakNG. For instance C:\Program Files (x86)\eSpeak NG\libespeak-ng.dll or whatever it is on your computer. Add that path to the PHONEMIZER_ESPEAK_LIBRARY environment variable (I don't know how to do it on Windows) and it should work.

djpelu commented 1 year ago

i checked many times and the path is correct, however it's still not working. thank you again for your help, hope i can find a solution and post it here for anyone that may need it

djpelu commented 1 year ago

tt

this is what i've done. If someone knows why this doesn't work on windows, let me know. Thank you!

QuLiao1117 commented 1 year ago

Did you solve that problem now? I meet the same problem with you.

hildazzz commented 1 year ago

Me too! Please let me know if this problem solved. Thanks!

djpelu commented 1 year ago

Unfortunately I couln’t find a solution and i had to resort to another package

LingXuanYin commented 1 year ago

Hey ,I've solved this !

(0) you need to comment out line75-80 in venv\Lib\site-packages\phonemizer\backend\espeak\base.py like this:

        if not self.is_available():
            pass
            #raise RuntimeError(  # pragma: nocover
                #'{} not installed on your system'.format(self.name()))

(1) Install espeak with cmd command winget install espeak or download exe and install :https://sourceforge.net/projects/espeak/files/espeak/espeak-1.48/setup_espeak-1.48.04.exe/download

(2) Install espeak-ng https://github.com/espeak-ng/espeak-ng/releases

(3) Copy the espeak-ng's dll C:\Program Files\eSpeak NG\libespeak-ng.dll to C:\Program Files (x86)\eSpeak\command_line and rename it to espeak-ng.dll or espeak.dll

(4) Add C:\Program Files (x86)\eSpeak\command_line to environment variable Path

(5) Restart your vscode/cmd/Jupyter or anything you run VITS or something else

You can uninstall eSpeak NG after you've done this @QuLiao1117 @djpelu @Skye-ZHAO

mmmaat commented 1 year ago

FYI we have a working workflow of installing espeak with phonemizer on Windows within our github actions: https://github.com/bootphon/phonemizer/blob/master/.github/workflows/windows.yaml

Basically on PowerShell you have to do:

# Install espeak-ng-1.50
$source = 'https://github.com/espeak-ng/espeak-ng/releases/download/1.50/espeak-ng-20191129-b702b03-x64.msi'
Invoke-WebRequest -Uri $source -OutFile espeak.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I espeak.msi /qn'

# Set the environment variable with the espeak-ng DLL (I'm not sure of that, took from [1] but didn't tested)
[Environment]::SetEnvironmentVariable('PHONEMIZER_ESPEAK_LIBRARY', 'C:\\Program Files\eSpeak NG\libespeak-ng.dll', 'Machine')

# Finally install phonemizer
python setup.py install
phonemizer --version

Can someone on Windows can test it? Hope this helps...


[1] https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.2#saving-environment-variables-with-setenvironmentvariable

Excurs1ons commented 1 year ago

In Anaconda environment, install espeak-ng then conda env config vars set PHONEMIZER_ESPEAK_PATH=“C:\Program Files\eSpeak NG” conda env config vars set PHONEMIZER_ESPEAK_LIBRARY="C:\Program Files\eSpeak NG\libespeak-ng.dll" It just worked.

Cmaury commented 1 year ago

I was able to root cause this issue, at least for myself and on windows. I was getting the same error, and it turns out there was a mismatch between my python system, which is 64bit and my espeak instal which was 32bit. My espeak and espeak NG installs were x86 but running:

'python -c "import platform; print(platform.architecture())"'

if you update espeak NG to match your system (64bit and 64bit) it should work and find the library once you've updated your environment variables.

I only found this by commenting our the initial error, and getting a more detailed error message when it failed further downstream.

corvusMidnight commented 1 year ago

I was able to root cause this issue, at least for myself and on windows. I was getting the same error, and it turns out there was a mismatch between my python system, which is 64bit and my espeak instal which was 32bit. My espeak and espeak NG installs were x86 but running:

'python -c "import platform; print(platform.architecture())"'

if you update espeak NG to match your system (64bit and 64bit) it should work and find the library once you've updated your environment variables.

I only found this by commenting our the initial error, and getting a more detailed error message when it failed further downstream.

There must be some issues with Windows 10 x64bit (see here). How did you install the 64bit version of espeak?

ziyaad30 commented 1 year ago

Just edit anaconda3\envs\FreeVC\Lib\site-packages\phonemizer\backend\espeak\wrapper.py

class EspeakWrapper:
    """Wrapper on espeak shared library

    The aim of this wrapper is not to be exhaustive but to encapsulate the
    espeak functions required for phonemization. It relies on a espeak shared
    library (*.so on Linux, *.dylib on Mac and *.dll on Windows) that must be
    installed on the system.

    Use the function `EspeakWrapper.set_library()` before instanciation to
    customize the library to use.

    Raises
    ------
    RuntimeError if the espeak shared library cannot be loaded

    """
    # a static variable used to overload the default espeak library installed
    # on the system. The user can choose an alternative espeak library with
    # the method EspeakWrapper.set_library().
    _ESPEAK_LIBRARY = 'C:\Program Files\eSpeak NG\libespeak-ng.dll'
younengma commented 1 year ago

Editting the file C:\ProgramData\Anaconda3\Lib\site-packages\phonemizer\backend\espeak.py works fine. I tried to add environment variables, it doesn't work. directly return the absolutely path in the following function works for me. phonemizer version is 2.2.1.

class BaseEspeakBackend(BaseBackend) : def espeak_path(): """Returns the absolute path to the espeak executable"""

directly return the espeak path

          return  r"C:\Program Files\eSpeak NG\espeak-ng.exe"
ziyaad30 commented 1 year ago

Better method

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

Better method

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

It indeed works!

nehc0 commented 1 year ago

Better method

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

Thank you very much!

RomanVD39 commented 1 year ago

Nothing works. The same issue on fresh win 10 and pip installation.\ "RuntimeError: espeak not installed on your system"

RomanVD39 commented 1 year ago

from phonemizer.backend.espeak.wrapper import EspeakWrapper print(EspeakWrapper.library()) ->C:\Program Files (x86)\eSpeak NG\libespeak-ng.dll

But when use phonemize(): ... ... ... File "D:\PyProjects\LV\venv\Lib\site-packages\phonemizer\backend\base.py", line 77, in init raise RuntimeError( # pragma: nocover RuntimeError: espeak not installed on your system

Any help?

RomanVD39 commented 1 year ago

I have uninstalled espeak-ng-X86.msi then installed espeak-ng-X64.msi

So, C:\Program Files (x86)\eSpeak NG\libespeak-ng.dll was changed to C:\Program Files\eSpeak NG\libespeak-ng.dll

And this

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

works fine!

Be careful for right msi version!

Kkordik commented 12 months ago

Guys, nothing worked for me from here, so I asked bing chat.

bing answer: “Reboot the system: Sometimes changes in environment variables do not take effect until the system is rebooted.”

Finally worked. I've wasted 2 hours on this.

BarathwajAnandan commented 10 months ago

for linux or WSL users, Instead of doing pip install espeak, try 'sudo apt-get install espeak-ng' worked for me.

audiocommander commented 10 months ago

fyi, I'm not on Windows, but on Mac OS Sonoma (ARM64, M2) and I have exactly the same troubles, hours sinking into this install. I have installed espeak via brew, it's available on zsh, I can open it and synthesise speech. I tried installed espeak-ng via pip (failed), via brew (kinda worked), via ports (worked) and made sure that I exported all paths correctly as seen here and otherwhere.

So, on shell, I have espeak, on python shell I can access espeakng, seems all good. But Juypter still tells me I haven't installed espeak. So I guess, this is rather an issue of how this library accesses espeak. I admit, I don't understand, why we need to handle full paths to dynamic libs when the full program command is available on my shell and thus also in python; isn't this the point of having conda and pip and such?

Trying a reboot now as a last step before giving up...

jncasey commented 10 months ago

It's been a while since I installed it on my M1 Mac, but I'm pretty sure I had to compile espeak-ng from source to get it working

cmp-nct commented 10 months ago

Took me 2 hours to get espeak working with phonemizer. That issue should not have been closed without implementing the needed changes so people do not have to waste so much time. That should be bold information in the readme on the frontpage

sunnnnnnnny commented 9 months ago

@audiocommander For macos, if use brew install espeak; it only need change some code of ctypes package that find find_library function; Especially, edit miniconda3/envs/env/lib/pythonx/ctypes/util.py file with find_library function‘s possible variable(actually espeak lib path is /opt/homebrew/lib), it works for me;

mmmaat commented 9 months ago

@sunnnnnnnny this is usually a bad idea to edit files from the standard library... Instead you may want to set the environment variable PHONEMIER_ESPEAK_LIBRARY=/opt/homebrew/lib/espeak.dylib (or the actual path to the espeak library on your machine). Or you can use/adapt this Python snippet:

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

@sunnnnnnnny this is usually a bad idea to edit files from the standard library... Instead you may want to set the environment variable PHONEMIER_ESPEAK_LIBRARY=/opt/homebrew/lib/espeak.dylib (or the actual path to the espeak library on your machine). Or you can use/adapt this Python snippet:

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

ok,thanks; i see it;

mmmaat commented 9 months ago

Ok... This issue seems to cause a lot of troubles since a long time... I just updated the Windows installation instructions (https://bootphon.github.io/phonemizer/install.html#on-windows). Hope this helps.

I do not use - and don't know much about - Windows or MacOS so it's difficult for me to help or replicate problems from this thread.

Anyway I welcome any PR with improvement on the documentation from Windows/macOs users :1st_place_medal:, thank you!

cmp-nct commented 9 months ago

Ok... This issue seems to cause a lot of troubles since a long time... I just updated the Windows installation instructions (https://bootphon.github.io/phonemizer/install.html#on-windows). Hope this helps.

I do not use - and don't know much about - Windows or MacOS so it's difficult for me to help or replicate problems from this thread.

Anyway I welcome any PR with improvement on the documentation from Windows/macOs users 🥇, thank you!

Add this hint to the Windows instructions: conda env config vars set PHONEMIZER_ESPEAK_PATH=“C:\Program Files\eSpeak NG” conda env config vars set PHONEMIZER_ESPEAK_LIBRARY="C:\Program Files\eSpeak NG\libespeak-ng.dll"

I've tried a ton of things, including renaming the library (removing lib from libespeak-ng.dll removed 50% of the errors but then it got stuck again) or copying it into system32, nothing worked to get through the "layers of detection", those two environment variables did it.

teddybear082 commented 9 months ago

In Anaconda environment, install espeak-ng then conda env config vars set PHONEMIZER_ESPEAK_PATH=“C:\Program Files\eSpeak NG” conda env config vars set PHONEMIZER_ESPEAK_LIBRARY="C:\Program Files\eSpeak NG\libespeak-ng.dll" It just worked.

THANK YOU SO MUCH. I spent over an hour this morning trying to get espeak phonemizer, which is a depency of styletts2, working on my system with anaconda, and your solution finally solved it

iackov commented 6 months ago

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)

matmult commented 6 months ago

@sunnnnnnnny this is usually a bad idea to edit files from the standard library... Instead you may want to set the environment variable PHONEMIER_ESPEAK_LIBRARY=/opt/homebrew/lib/espeak.dylib (or the actual path to the espeak library on your machine). Or you can use/adapt this Python snippet:

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

This finally fixed it for me, but using export PHONEMIZER_ESPEAK_LIBRARYPATH="/opt/homebrew/Cellar/espeak/1.48.04_1/lib/libespeak.dylib" is still broken for me on zsh. Am I using the wrong env variable name?