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

How to build and install on macOS? #37

Closed
dosentmatter opened this issue Dec 11, 2020 · 14 comments
Closed

How to build and install on macOS? #37

dosentmatter opened this issue Dec 11, 2020 · 14 comments

Comments

@dosentmatter
Copy link
Contributor

dosentmatter commented Dec 11, 2020

I am on macOS Mojave 10.14.6.

I looked at macOS install instructions in INSTALL. I can't get past the ./configure or make steps. Do you have any suggestions? I'm not sure what version of gcc is required. I'm interested in trying out the toisanese TTS.

Setup:

$ cd ekho-8.3
$ brew install pulseaudio gcc5

$ # I built and installed espeak-ng by following instructions here
$ # https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md#linux-mac-bsd
$ cd espeak-ng
$ glibtoolize -c
$ ./autogen.sh
$ ./configure --prefix=/usr/local
$ make
$ make install

Configure:
I tried the following without success.

$ cd ekho-8.3
$ ./configure --without-pulseaudio CC=gcc-5 CXX=g++-5
configure: WARNING: unrecognized options: --without-pulseaudio
checking for gcc... gcc-5
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/Users/kl94333/Downloads/ekho-8.3':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
$ ./configure CC=gcc-5 CXX=g++-5
checking for gcc... gcc-5
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/Users/kl94333/Downloads/ekho-8.3':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
$ ./configure CC=gcc-10 CXX=g++-10
...
checking for setlocale... yes
checking for strstr... yes
checking for main in -lsndfile... no
configure: error: in `/Users/kl94333/Downloads/ekho-8.3':
configure: error: sndfile test failed
See `config.log' for more details
$ clang --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ ./configure CC=clang CXX=clang  # works
$ make
./utfcpp/source/utf8/unchecked.h:53:62: note: place parentheses around the '&' expression to silence this warning
                *(result++) = static_cast<uint8_t>((cp >> 12)& 0x3f   | 0x80);
                                                             ^
                                                   (               )
./utfcpp/source/utf8/unchecked.h:54:62: warning: '&' within '|' [-Wbitwise-op-parentheses]
                *(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f   | 0x80);
                                                   ~~~~~~~~~~^~~~~~   ~
./utfcpp/source/utf8/unchecked.h:54:62: note: place parentheses around the '&' expression to silence this warning
                *(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f   | 0x80);
                                                             ^
                                                   (               )
In file included from src/test_ekho.cpp:29:
src/ekho.h:93:60: error: default arguments can only be specified for parameters in a function declaration
  typedef int(SynthCallback)(short *pcm, int frames, void *arg = NULL,
                                                           ^     ~~~~
src/ekho.h:94:42: error: default arguments can only be specified for parameters in a function declaration
                             OverlapType type = OVERLAP_QUIET_PART);
                                         ^      ~~~~~~~~~~~~~~~~~~
6 warnings and 2 errors generated.
make: *** [src/test_ekho-test_ekho.o] Error 1
@dosentmatter dosentmatter changed the title How to build and install on macOS How to build and install on macOS? Dec 11, 2020
@dosentmatter
Copy link
Contributor Author

I wasn't able to figure out how to build on macOS, but I instead found a way to build it in a debian docker image and play the audio using pulseaudio over the local network to my mac host.

@hgneng, would you like me to create a PR with the Dockerfile and instructions? We could also publish the image on dockerhub for an easy cross-platform install.

@hgneng
Copy link
Owner

hgneng commented Dec 14, 2020

I have never built Ekho on Mac. Ekho use pulseaudio to run but pulseaudio is not running on Mac.

I am not familiar with PR or Docker. If you think others will benefit from your work, go ahead. I will put your work on Ekho's page. Thank you!

@dosentmatter
Copy link
Contributor Author

dosentmatter commented Dec 20, 2020

I tried building on macOS with libpulseaudio and libsndfile installed but I kept getting errors, so I gave up.

PR means Pull Request. I have a Pull Request coming soon to be able to run ekho on macOS and Windows through a docker container.

Docker is software that allows running containers through OS-level virtualization. You can think of a container as a lightweight VM.

I got ekho running on a Docker container on different OS's using the following methods:

Linux:

  • Add the host's /dev/snd device to the container.
  • Run ekho inside the container. This plays audio on the host through the dev/snd device.

Although ekho can be built and run on Linux, the benefit of using Docker is to skip having to build ekho yourself.

macOS or Windows (PowerShell/WSL):

  • Run pulseaudio server on the host.
  • In the container, set PULSE_SERVER env variable to point to the pulseaudio server
  • Run ekho inside the container. This plays audio on the host through pulseaudio network audio.

@hgneng
Copy link
Owner

hgneng commented Dec 22, 2020

I have fixed build issues on MacOS. Please try following version:
https://sourceforge.net/projects/e-guidedog/files/Ekho/8.5/

Thank you for opening this issue. I have never thought that Ekho can port to MacOS easily.

You need to launch pulseaudio deamon first. In my environment, pulseaudio installed from HomeBrew is not able to launch. But I can run it by pulseaudio. However, pulseaudio runs very unstable.

At least, you can out wave to a file with ./ekho "some text" -o demo.wav and play it with play demo.wav

@dosentmatter
Copy link
Contributor Author

dosentmatter commented Dec 22, 2020

Hey @hgneng, thanks for the fix. I got it built and installed with macOS-provided clang and also homebrew-provided clang, although with a lot of warnings.

You can start pulseaudio daemon with brew services start pulseaudio. If you are having issues, try restarting it with brew services restart pulseaudio.

I wasn't able to get gcc-10 to work though. For some reason, /usr/local/include isn't part of my gcc-10 include path and /usr/local/lib isn't part of my libs, so I tried ./configure CC=gcc-10 LDFLAGS=-L/usr/local/lib CPPFLAGS='-I/usr/local/include' CXX=g++-10, without success. It still says ld: symbol(s) not found for architecture x86_64. Oh well, it's not a big deal since clang works.

So here are my steps to get it working:

$ brew install pulseaudio libsndfile
$ brew install llvm # optional if you want to build with homebrew clang

$ # Have to install libespeak-ng manually because it's not provided by homebrew.
$ # I built and installed espeak-ng by following instructions here
$ # https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md#linux-mac-bsd
$ cd espeak-ng
$ brew install libtool
$ # need to do this because `m4` has symlinks to /usr/share/aclocal
$ # whereas mac has it at /usr/local/share/aclocal, probably due to homebrew.
$ glibtoolize -c
$ ./autogen.sh
$ ./configure # default installed at /usr/local with --prefix=/usr/local
$ make
$ make install
$ espeak-ng # test this command to make sure no errors.

$ cd ekho-8.5
$ ./configure # this uses macOS clang

$ # alternatively use homebrew clang
$ ./configure CC=/usr/local/opt/llvm/bin/clang LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include'CXX=/usr/local/opt/llvm/bin/clang++

$ make
$ make install
$ brew services restart pulseaudio # this ensures pulseaudio daemon is started
$ ekho 123 # should work now

@hgneng
Copy link
Owner

hgneng commented Dec 23, 2020

Thank you for the detail procedures.

I have trouble with start pulseaudio service in brew. I think it's an issue of my Homebrew environment.

$ brew services start pulseaudio
Error: undefined method `named' for #<OptionParser:0x00007f9b3aaa0cd0>
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/lib/services_cli.rb:75:in `run!'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/cmd/services.rb:48:in `services'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in `<main>'

@dosentmatter
Copy link
Contributor Author

No problem.

Hmm, those errors are within the homebrew ruby code. I wonder how that happened. I found these issues:
Homebrew/homebrew-services#251
Homebrew/homebrew-bundle#751

They say to update or reinstall homebrew.

@dosentmatter
Copy link
Contributor Author

dosentmatter commented Dec 23, 2020

@hgneng, you mentioned that your pulseaudio is runs unstably even when you run it manually.

Here is the homebrew plist. plists are daemon configuration files for macOS launchd service.

Here it is evaluated on my mac:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>homebrew.mxcl.pulseaudio</string>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/opt/pulseaudio/bin/pulseaudio</string>
    <string>--exit-idle-time=-1</string>
    <string>--verbose</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>KeepAlive</key>
  <true/>
  <key>StandardErrorPath</key>
  <string>/usr/local/var/log/pulseaudio.log</string>
  <key>StandardOutPath</key>
  <string>/usr/local/var/log/pulseaudio.log</string>
</dict>
</plist>

Notice the --exit-idle-time=-1 flag. If you don't set that, it defaults to 20. The default is shown and commented out in /usr/local/Cellar/pulseaudio/*/etc/pulse/daemon.conf as ; exit-idle-time = 20. If you leave it as default, pulseaudio will exit after 20 seconds of inactivity. From my experience, it seems to exit only after you play audio for one last time, ie. it exits when you play audio after 20+ seconds of inactivity.

Perhaps pulseaudio --exit-idle-time=-1 will help with your instability, if you aren't able to fix your homebrew services.

@hgneng
Copy link
Owner

hgneng commented Dec 24, 2020

Thank you! After running brew update, pulseaudio service runs normally.

Running brew update needs courage and lucky in China. Usually, it fails at a network issue after waiting for half an hour.

@dosentmatter
Copy link
Contributor Author

You're welcome! That's good that you got it working.

I guess we can close this issue now that we have ekho working for macOS?

@dosentmatter
Copy link
Contributor Author

dosentmatter commented Dec 24, 2020

@hgneng, I saw your blog post about building espeak-ng on macOS.

I saw you mentioned there was no sound for the espeak-ng CLI.

You typed:

espeak-ng 'hello' # no sound

espeak-ng 'hello' -w demo.wav && play demo.wav # works

There are actually a few ways to fix that instead of outputting to a .wav file.

First things first, play isn't included in macOS by default, you have to brew install sox

Option 1 play from stdin:

brew install sox
espeak-ng hello | play -

If you want sound from espeak-ng directly, you need to install pcaudiolib.
See:
https://github.com/espeak-ng/espeak-ng/blob/master/docs/guide.md#problems-with-pcaudiolib
https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md#linux-mac-bsd

pcaudiolib also isn't provided by brew so need to be built and installed manually. The guides list a bunch of other optional dependencies you can install such as sonic to speed up audio. If you install sonic, make sure to install from the source and not the espeak-ng fork, because it is out of date.

The espeak-ng ./configure command will tell you if you have dependencies installed correctly.

Option 2 Here is a quick guide for a fuller espeak-ng install on macOS:

# https://github.com/espeak-ng/pcaudiolib#mac-os
cd pcaudiolib
./autogen.sh
./configure
make
make install

# Use https://github.com/waywardgeek/sonic instead of out-of-date https://github.com/espeak-ng/sonic
cd sonic
brew install fftw
make
make install PREFIX=/usr/local

cd espeak-ng
glibtoolize -c
./configure --with-extdict-zh --with-extdict-zhy
make
make install

# test audio:
espeak-ng -vyue '冚挷攔'

@zhangtengyuan
Copy link

zhangtengyuan commented Dec 28, 2020 via email

@dosentmatter
Copy link
Contributor Author

@zhangtengyuan, I'm not sure what you are talking about. You might have subscribed to this issue accidentally. Click "Unsubscribe" on the top-right to unsubscribe from emails.

image

@hgneng
Copy link
Owner

hgneng commented Dec 28, 2020

@dosentmatter, Thank you for the details about espeak-ng. The original link of sonic and config command for extra dictionary is valuable to me.

@hgneng hgneng closed this as completed Apr 20, 2021
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

3 participants