Installation
Dependencies
You need python>=3.10. If you are using an older python version, use the
phonemizer-3.4 release, pip selects it automatically. If you really need
to use python2, use the phonemizer-1.0 release.
You need to install
festival,
espeak-ng
and/or mbrola in order to use the
corresponding phonemizer backends. The segments backend is a Python
package, installed with pip install phonemizer[segments] (see below).
The espeak backend requires espeak>=1.48 or espeak-ng (the espeak-mbrola
backend requires espeak-ng). Follow instructions for your system below.
On Debian/Ubuntu
To install dependencies, simply run
sudo apt-get install festival espeak-ng mbrola
When using the espeak-mbrola backend, additional mbrola voices must be installed (see the espeak-ng documentation on mbrola). List the installable voices with
apt search mbrola
On CentOS/Fedora
To install dependencies, simply run
sudo yum install festival espeak-ng
When using the espeak-mbrola backend, the mbrola binary and additional mbrola voices must be installed (see the espeak-ng documentation on mbrola).
On MacOS
espeak-ng is available on brew:
brew install espeak-ng
festival and mbrola are not packaged for MacOS (neither by brew nor
by MacPorts) and must be compiled from sources. Note that phonemizer is not
tested with them on MacOS.
mbrola: follow the compilation instructions of the MBROLA repository, then copy the
Bin/mbrolaexecutable to a folder in yourPATH. The voices are available from the MBROLA-voices repository, copy them to thembrolafolder of the espeak-ng data directory (as given byespeak-ng --version).festival: follow the festival install guide (compile the speech tools, then festival with its English lexicons and voices), then give the path to the festival executable to
phonemizer(see Custom espeak and festival installations).
The setup-festival-mbrola script formerly suggested here is archived and no longer works (see issue #203).
On Windows
Install espeak-ng with the .msi Windows installer provided with espeak releases.
Warning
On Windows the installation of espeak can cause issues (see issue #44).
Make sure you install the correct .msi file for your platform. It exists
for two architectures: X64 and X86. Most today’s machines are X64 so, if you
don’t know which one to choose, you should start trying with
espeak-ng-X64.msi.
If phonemizer fails with a message RuntimeError: espeak not installed
on your system, see espeak not installed on your system.
festival must be compiled from sources (see the festival install guide and this tutorial). mbrola is not available for Windows.
Custom espeak and festival installations
By default phonemizer uses the espeak library, the espeak data and the
festival program found on the system. You can choose others from Python,
before calling phonemizer.phonemize():
from phonemizer.backend import FestivalBackend
from phonemizer.backend.espeak.wrapper import EspeakWrapper
EspeakWrapper.set_library('/path/to/libespeak-ng.so')
EspeakWrapper.set_data_path('/path/to/espeak-ng-data')
FestivalBackend.set_executable('/path/to/festival')
or with environment variables:
export PHONEMIZER_ESPEAK_LIBRARY=/path/to/libespeak-ng.so
export PHONEMIZER_ESPEAK_DATA_PATH=/path/to/espeak-ng-data
export PHONEMIZER_FESTIVAL_EXECUTABLE=/path/to/festival
The data path is the espeak data directory, containing the phontab file
(with espeak<1.49 it must be named espeak-data). The values set from Python
take precedence over the environment variables.
From the command line, use the --espeak-library and
--festival-executable options.
Phonemizer
The simplest way is using pip:
pip install phonemizer
To use the segments backend, install the optional dependencies with:
pip install phonemizer[segments]
OR install it from sources with:
git clone https://github.com/bootphon/phonemizer cd phonemizer pip install .[segments]
If you experience an error such as
ImportError: No module named setuptoolsduring installation, refer to issue #11.
Docker image
Alternatively you can run the phonemizer within docker, using the
provided Dockerfile. The image includes espeak-ng, festival, mbrola with
the French voice, and runs the tests at build time. To build the docker image,
have a:
git clone https://github.com/bootphon/phonemizer
cd phonemizer
sudo docker build -t phonemizer .
Then run an interactive session with:
sudo docker run -it phonemizer /bin/bash
Development
When installed from sources, you can run the tests suite from the root
phonemizer folder:
pip install .[test] # this installs pytest
pytest
To build this documentation, have a:
pip install .[doc]
make --directory=docs html
If you are a pixi user, the development environments are already configured:
pixi run test # run the tests
pixi run -e py310 test # run the tests on python-3.10
pixi run lint # check the code with ruff