syllables

raw JSON →
1.1.5 verified Sat May 09 auth: no python

A Python package for estimating the number of syllables in words, based on the CMU Pronouncing Dictionary. Current version 1.1.5 (2026-01-11), released on PyPI about every 1-6 months with dependency fixes.

pip install syllables
error ImportError: cannot import name 'get_syllable_count' from 'syllables'
cause The function was renamed from 'get_syllable_count' to 'estimate' in an older version (v1.0.7+).
fix
Replace 'from syllables import get_syllable_count' with 'from syllables import estimate' and call 'estimate(word)'.
error ModuleNotFoundError: No module named 'syllables'
cause Package not installed or environment not activated.
fix
Run 'pip install syllables'.
error AttributeError: module 'syllables' has no attribute 'estimate'
cause The installed version is too old (pre-1.0.7) or the import is wrong.
fix
Upgrade: 'pip install --upgrade syllables'. Use 'from syllables import estimate'.
deprecated The module 'syllables' was previously named 'syllables' but some old code may reference 'syllables.syllables' or 'from syllables import get_syllable_count'. Only 'from syllables import estimate' is correct.
fix Change imports to 'from syllables import estimate'.
gotcha The function is case-insensitive since v1.0.7, but non-ASCII words may not be in the CMU dictionary and will fall back to a naive estimate.
fix Test with non-English words; consider preprocessing.
gotcha The package uses the CMU Pronouncing Dictionary, which covers only American English. Words not in the dictionary (e.g., proper nouns, abbreviations) are estimated using a simple vowel-group count heuristic, which can be inaccurate.
fix Check if the output is -1 for unknown words (actually estimate returns a count for anything; use try-except? No exception, just fallback). Ensure inputs are English words.

Estimate syllable count for given words.

from syllables import estimate
print(estimate('hello'))  # Output: 2
print(estimate('cat'))    # Output: 1
print(estimate('world'))  # Output: 1