phonemizer is a simple yet powerful Python library that converts text to phonetic representations (phones) for multiple languages. It supports various backends like eSpeak, Festival, and Mbrola. The current version is 3.3.2, and it maintains an active, though somewhat irregular, release cadence, addressing bugs and adding improvements.
pip install phonemizerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates phonemizing a list of strings using the 'espeak' backend. It's crucial to have 'espeak' (or another chosen backend like 'festival') installed on your system, as they are external binaries, not Python packages. The language and backend are explicitly set for clarity and to avoid relying on default changes.
Ensure your Python environment is 3.8 or newer before installing or upgrading phonemizer.
Install your desired backend (e.g., `sudo apt-get install espeak` on Debian/Ubuntu, `brew install espeak` on macOS, or follow instructions for Festival/Mbrola) before using phonemizer.
Explicitly specify the `backend` argument (e.g., `backend='festival'` or `backend='espeak'`) to ensure consistent behavior, especially if migrating from versions prior to 3.0.
If you rely on empty lines being removed, filter your input list or process the output list accordingly. For example, `[line for line in phonemize(...) if line]`.
Update any scripts or system configurations that use the old environment variable or command-line option name to the new `_LIBRARY` suffix.
Always pass a list of strings to `phonemize`, even if it's a single item (e.g., `phonemize(['my text'])` instead of `phonemize('my text')`).First, install `espeak-ng` on your operating system (e.g., `sudo apt-get install espeak-ng` on Debian/Ubuntu, `brew install espeak` on macOS). On Windows, use the `.msi` installer. If `espeak-ng` is still not found, especially on Windows or if it's in a non-standard location, explicitly set the path to its library using `PHONEMIZER_ESPEAK_LIBRARY` environment variable or in Python: `from phonemizer.backend.espeak.wrapper import EspeakWrapper; EspeakWrapper.set_library('C:\Program Files\eSpeak NG\libespeak-ng.dll')` (adjust path for your system).Ensure `espeak-ng` is correctly installed and updated on your system, as it supports a wide range of languages. Verify that the language code you are using is accurate and is listed as supported by your selected backend. You can programmatically check supported languages for the eSpeak backend using `from phonemizer.backend.espeak import EspeakBackend; EspeakBackend.supported_languages()`.
Install the `segments` Python package using pip: `pip install segments`.
Pre-process the input text to handle or remove words that are likely to be unphonemizable (e.g., highly unusual proper nouns, non-standard spellings). For backends that support it, you can configure the behavior for unknown words (e.g., 'ignore', 'warn', or 'remove' mismatched lines) using parameters like `with_words_count_mismatch`. If using the `segments` backend, ensure a comprehensive grapheme-to-phoneme mapping is provided.
No dependency data recorded yet.