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

Piper does not work on macOS: /usr/lib/libespeak-ng.1.dylib (no such file) #404

Open
mapleroyal opened this issue Feb 18, 2024 · 10 comments

Comments

@mapleroyal
Copy link

Whether downloading the release, or cloning the repo, I'm getting this error:

echo 'Welcome to the world of speech synthesis!' | ./piper --model /Users/user1/Downloads/piper/en_US-ryan-high.onnx  --output_file output.wav
dyld[38295]: Library not loaded: @rpath/libespeak-ng.1.dylib
  Referenced from: <65D01FDC-B71E-3786-8B0D-0BFEEC801633> /Users/user1/Downloads/piper/piper
  Reason: tried: '/usr/local/lib/libespeak-ng.1.dylib' (no such file), '/usr/lib/libespeak-ng.1.dylib' (no such file, not in dyld cache)
fish: Process 38295, './piper' from job 1, 'echo 'Welcome to the world of s…' terminated by signal SIGABRT (Abort)
@williamcorney
Copy link

williamcorney commented Feb 25, 2024

See this post for a solution

rhasspy/piper-phonemize#14

@mapleroyal
Copy link
Author

mapleroyal commented Feb 25, 2024

See this post for a solution

rhasspy/piper-phonemize#14

Thanks for the suggestion. I read that and a thread linked therein, but unfortunately could not find a mention of libespeak-ng.1.dylib anywhere.

Additionally, the discussions seem unrelated, primarily focusing on manually building piper and the numerous layered difficulties and complications of doing so, which I'm unable to follow—whereas my issue is specifically regarding the prebuilt release (from Releases or via cloning the repo) and the usage instructions for it given in the main readme.

@Revmagi
Copy link

Revmagi commented Apr 1, 2024

I am having the same issues. if there are dependancies for a recompiled package there should be instructions for getting it running.

@dspasyuk
Copy link

dspasyuk commented May 2, 2024

@Revmagi @mapleroyal Try the guide (script piper_install_mac.sh) here, let me know if you have any issue: https://github.com/dspasyuk/llama.cui

@williamcorney
Copy link

williamcorney commented May 2, 2024

Hopefully the guidance on the page dspasyuk linked will help

I created wheels for intel based macs that will work on many recent versions of python 3.12, 3.11 . I didnt have ability to create a silicon wheel because I dont have such a mac . It would be useful if someone with a silicon Mac builds wheels to make the process simpler for those who follow.

I tried out of curiosity to investigate further the issue with the standalone install of the prepackaged binary
The issue seems to be around the location and/or presence of certain files such as libespeak-ng.1.dylib, libonnxruntime.1.14.1.dylib in certain locations.

you cannot simply just download and unzip the release and it just works out of the box. You will have to install espeak-ng separately and make sure that the files the program requires are either placed in the relevant folder, there are symbol links (alias files) or you pass command line parameters ( where applicable) to tell the program to look elsewhere. it's probably possibly to make it work if you can figure out all the dependencies and locations.

I was able to make a little progress by tinkering but without more in depth error messages showing exactly where the program was looking for said file(s) I only got so far.

I figured out how to get it installed, largely from the help of another forum post which gave me a deeper understanding of how to build, and also after much trial and error . I built from source, then created wheels (which have the dependencies embedded) , then used my own wheels to install it piper-tts / piper-phonemize with pip.

iF you build it from source yourself you need to install cmake with brew, prob have command line Xcode tools ( or whatever it's called) as this contains the header files needed for many build processes. a basic understanding of how you compile from source using make /cmake etc is helpful - you can prob find YouTube videos to fill in gaps of knowledge

@ruleset
Copy link

ruleset commented May 11, 2024

TL;DR
@dspasyuk is a particular version of MacOs required?
@mapleroyal probably building from source is better than the binaries. Especially if you are on macos < 12.6.
@williamcorney I agree with "without more in depth error messages showing exactly where the program was looking for said file(s) I only got so far."

the details
It seemed that the pre-built binary needed only a little help, as shown in the lama.cui shell script.
So I added each environment variable and dependency until I ran into what looks like an OS version requirement.

echo 'Welcome to the world of speech synthesis!' |   ./piper --model en_US-lessac-medium.onnx --output_file welcome.wav
  dyld: Library not loaded: @rpath/libespeak-ng.1.dylib
    Referenced from: ~/piper/./piper
    Reason: image not found
  Abort trap: 6
brew install espeak-ng
brew info espeak-ng
  ==> espeak-ng: stable 1.51, HEAD
  Speech synthesizer that supports more than hundred languages and accents
  https://github.com/espeak-ng/espeak-ng
  Installed
  /usr/local/Cellar/espeak-ng/1.51 (513 files, 12.9MB) *
    Built from source on 2024-05-11 at 16:50:51
  From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/e/espeak-ng.rb
  License: GPL-3.0-or-later and BSD-2-Clause
  ==> Dependencies
  Build: autoconf ✔, automake ✔, libtool ✔
  ==> Options
  --HEAD
    Install HEAD version
echo 'Welcome to the world of speech synthesis!' |   ./piper --model en_US-lessac-high.onnx --output_file welcome.wav
  dyld: Library not loaded: @rpath/libpiper_phonemize.1.dylib
    Referenced from: ~/piper/./piper
    Reason: image not found
  Abort trap: 6    
# NOTE: I manually installed https://github.com/rhasspy/piper-phonemize/releases/tag/2023.11.14-4
# untarred, and moved it under the piper directory.
# piper seemed to ignore the executable ./piper_phonemize
# There did not seem to be a USAGE or help describing how to specify binary piper_phonemize as an arg.
./piper --help
# same as last error reported

# Then, I added piper-phonemize to the path.
export DYLD_LIBRARY_PATH=/usr/local//Cellar/espeak-ng/1.51/lib/:./piper-phonemize/lib/
echo 'Welcome to the world of speech synthesis!' |   ./piper --model en_US-lessac-medium.onnx --output_file welcome.wav
  dyld: Library not loaded: @rpath/libpiper_phonemize.1.dylib
    Referenced from: ~/piper/./piper
    Reason: no suitable image found.  Did find:
    ./piper-phonemize/lib//libpiper_phonemize.1.dylib: code signature in (./piper-phonemize/lib/libpiper_phonemize.1.dylib) not valid for use in process using Library Validation: library load disallowed by system policy
  Abort trap: 6
# I then used manual right-click & Open on the libs that MacOs did not trust.
# The usual prompt asks "macOS cannot verify the developer of libpiper_phonemize. Are you sure you want to open it?"
# I clicked open.
# So now dependencies, environment, and OS trust issues are resolved.
echo 'Welcome to the world of speech synthesis!' |   ./piper --model en_US-lessac-high.onnx --output_file welcome.wav
  dyld: Symbol not found: _espeak_TextToPhonemesWithTerminator
    Referenced from: ./piper-phonemize/lib//libpiper_phonemize.1.dylib (which was built for Mac OS X 12.6)
    Expected in: /usr/local//Cellar/espeak-ng/1.51/lib//libespeak-ng.1.dylib

  Abort trap: 6

_espeak_TextToPhonemesWithTerminator may be some private symbol in libespeak-ng?
Building from source would seem easier than investigating _espeak_TextToPhonemesWithTerminator

@dspasyuk
Copy link

dspasyuk commented May 12, 2024

Hi @ruleset, have you tried running the script I provided in https://github.com/dspasyuk/llama.cui repo? If you want to redo compilation manually you will need to set paths to all the brew libraries as described in piper_install_mac.sh. So for espeak: echo 'export DYLD_LIBRARY_PATH=/opt/homebrew/Cellar/espeak-ng/1.51/lib/:$DYLD_LIBRARY_PATH' >> ~/.zprofile The script has been tested on MacOS Venture 13.2.1

@jdeltoft
Copy link

This may help. I was able to use pipx to run this on my mac book. Shared my quick thoughts here: #217 (comment)

@TeemuKoivisto
Copy link

Hi @ruleset, have you tried running the script I provided in https://github.com/dspasyuk/llama.cui repo? If you want to redo compilation manually you will need to set paths to all the brew libraries as described in piper_install_mac.sh. So for espeak: echo 'export DYLD_LIBRARY_PATH=/opt/homebrew/Cellar/espeak-ng/1.51/lib/:$DYLD_LIBRARY_PATH' >> ~/.zprofile The script has been tested on MacOS Venture 13.2.1

I was able to get it running with your script, thanks! Seems you have to build it from the source directly since neither binary or piper-tts works at least for my ARM mac.

@vsenn
Copy link

vsenn commented Oct 18, 2024

well. I managed to get it running after building from source according to https://github.com/dspasyuk/llama.cui but got this

piper/build on  master [!] via △ v3.30.5 
❯ echo 'Welcome to the world of speech synthesis!' | \
  ./piper --model en_US-lessac-medium.onnx --output_file welcome.wav
dyld[47618]: Symbol not found: _espeak_TextToPhonemesWithTerminator
  Referenced from: <6EAB2501-8681-3D85-B3C1-D64FAEEB81B4> /Users/xyz/Documents/piper/piper/build/pi/lib/libpiper_phonemize.1.2.0.dylib
  Expected in:     <0BBC92CF-9C82-31BD-90EC-FD70DDC98B12> /opt/homebrew/Cellar/espeak-ng/1.51/lib/libespeak-ng.1.dylib
zsh: done       echo 'Welcome to the world of speech synthesis!' | 
zsh: abort      ./piper --model en_US-lessac-medium.onnx --output_file welcome.wav

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