Pronouncing
Pronouncing is a lightweight Python library providing a simple interface to the CMU Pronouncing Dictionary. It allows users to programmatically access phonetic pronunciations, find rhyming words, count syllables, and search for words based on phonetic patterns. The current version is 0.2.0, with releases historically being infrequent, the last major update in 2018.
Warnings
- breaking Version 0.2.0 removed the CMU Pronouncing Dictionary data directly from the package. It now relies on the `cmudict` package as a dependency to provide this data. If upgrading from an older version (pre-0.2.0), ensure `cmudict` is installed.
- gotcha The `pronouncing.phones_for_word()` function can return multiple pronunciations for a single word, reflecting different possible ways a word can be spoken. The library does not provide built-in logic to determine the 'best' or 'most common' pronunciation.
- gotcha The library's development seems to be low-activity, with the last release (0.2.0) in 2018. While functional, new features or active maintenance should not be expected.
Install
-
pip install pronouncing
Imports
- pronouncing
import pronouncing
Quickstart
import pronouncing
word = "climbing"
rhymes = pronouncing.rhymes(word)
print(f"Rhymes for '{word}': {rhymes}")
pronunciations = pronouncing.phones_for_word(word)
print(f"Pronunciations for '{word}': {pronunciations}")
syllables = pronouncing.syllable_count(pronunciations[0]) # Use the first pronunciation for syllable count
print(f"Syllable count for '{word}': {syllables}")