Phonemizer

3.3.0 · active · verified Wed Apr 15

Phonemizer is a simple Python library for converting text into phonemes for multiple languages. It acts as a wrapper around various external phonemization backends like eSpeak, Festival, and Flite. The library is actively maintained with regular releases, typically addressing bug fixes, performance improvements, and adding new features.

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `phonemize` function and convert a list of text strings into their phonemic representations using the default `espeak` backend. It also highlights the essential prerequisite of installing an external phonemization engine.

from phonemizer import phonemize

# NOTE: This library requires an external phonemization backend (e.g., eSpeak)
# to be installed on your system. For Debian/Ubuntu:
# sudo apt-get install espeak
# For macOS:
# brew install espeak

texts = [
    "Hello, world!",
    "This is a test."
]

# Using the default 'espeak' backend (since v3.0)
# You can specify language (e.g., 'en-us') and backend ('espeak') explicitly.
phonemes = phonemize(texts, language='en-us', backend='espeak')

print("Original texts:", texts)
print("Phonemes:", phonemes)

# Example with a different separator
phonemes_with_separator = phonemize(
    texts,
    language='en-us',
    backend='espeak',
    separator='_'
)
print("Phonemes with custom separator:", phonemes_with_separator)

view raw JSON →