Registry / data / cmudict

cmudict

JSON →
library1.1.3pypypi✓ verified 24d ago

CMUdict (cmudict) is a Python wrapper package for the CMU Pronouncing Dictionary data files, providing access to over 134,000 English words and their ARPAbet pronunciations. It exposes the data with minimal assumptions on its usage. The library is actively maintained with frequent patch releases, often related to dependency updates or minor fixes, and occasional minor version bumps for features like type hints.

pip install cmudict
INSTALL
IMPORT
SIG · CMUDICT
C
cmudict
datapythonv1.1.3
Install
1.9s avg
Import
111ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.120s · 22.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.102s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cmudict
import cmudict
The primary module for accessing dictionary data.
dict
cmudict.dict()
cmudict.entries() for unique word lookups
`.dict()` returns a dictionary where keys are unique words and values are a list of their phonetic pronunciations. Use `cmudict.entries()` if you need a list of (word, pronunciation) tuples where a word with multiple pronunciations will appear multiple times.

This quickstart demonstrates how to initialize the CMU dictionary and retrieve pronunciations for a specific word using `cmudict.dict()`. It also highlights `cmudict.entries()` for iterating through all word-pronunciation pairs.

import cmudict # Get the full dictionary as a mapping from word to a list of pronunciations pron_dict = cmudict.dict() word = "hello" pronunciations = pron_dict.get(word) if pronunciations: print(f"Pronunciations for '{word}': {pronunciations}") # Example: Accessing the first pronunciation and its phonemes first_pronunciation_phonemes = pronunciations[0] print(f"First pronunciation phonemes: {first_pronunciation_phonemes}") else: print(f"'{word}' not found in CMUdict.") # To get all entries as (word, pronunciation) tuples (e.g., for iteration) all_entries = cmudict.entries() # print(f"Total entries (including variants): {len(all_entries)}") # Example of getting pronunciations via entries() (less direct for single word lookup) # target_word = "example" # example_pronunciations = [p for w, p in all_entries if w == target_word] # print(f"Pronunciations for '{target_word}' (from entries): {example_pronunciations}")
Debug
Known issues
gotchaThe methods `cmudict.dict()` and `cmudict.entries()` return data in different structures and are often confused. `cmudict.dict()` maps unique words to a list of their pronunciations, while `cmudict.entries()` returns a list of (word, pronunciation) tuples, meaning words with multiple pronunciations will have multiple entries in the list.
fix
Understand the return types: `cmudict.dict()` for direct word-to-pronunciations mapping, `cmudict.entries()` for iterating all individual word-pronunciation pairs.
affects: All versions
gotchaWords not found in the CMU Pronouncing Dictionary will result in `None` when using `cmudict.dict().get(word)` or an empty list when filtering `cmudict.entries()`. The dictionary is comprehensive but does not include all possible English words or numbers (which should be spelled out).
fix
Always check for `None` or an empty list when performing lookups: `if pronunciations: ... else: word_not_found_handling()`.
affects: All versions
breakingVersions `1.0.7`, `1.0.8`, and `1.0.9` were yanked from PyPI due to a 'broken deployment process'. Attempting to install these specific older versions will likely fail or lead to unexpected behavior.
fix
Avoid installing these specific yanked versions. Use the latest stable version (e.g., `pip install cmudict`) or a known working older version.
affects: 1.0.7, 1.0.8, 1.0.9
deprecatedAs of v1.1.1, internal typing hints were updated to use built-in types (`list`, `tuple`) instead of deprecated `typing.List` and `typing.Tuple`. While not directly breaking for most users, this reflects a move towards more modern Python typing conventions.
fix
Ensure your environment is compatible with Python 3.9+ for the best type hint experience, and update to `cmudict>=1.1.1` to benefit from these internal improvements.
affects: <1.1.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cmudict'
The 'cmudict' Python package is not installed in the environment where the code is being executed.
fix
Install the package using pip: `pip install cmudict`
KeyError: 'WORD'
The queried word does not exist in the CMU Pronouncing Dictionary data loaded by the `cmudict` library, which is a finite lexicon.
fix
Before accessing a word's pronunciation, check if the word exists in the dictionary: `import cmudict; d = cmudict.dict(); word = 'UNKNOWNWORD'; if word.upper() in d: print(d[word.upper()])`
TypeError: 'module' object is not subscriptable
The user attempted to access the `cmudict` module directly using dictionary-like square bracket notation (e.g., `cmudict['WORD']`), rather than calling one of its data access functions like `cmudict.dict()` first.
fix
Access the dictionary data by calling the appropriate function, such as `cmudict.dict()`, which returns a dictionary object: `import cmudict; pronunciation_dict = cmudict.dict(); word = 'EXAMPLE'; print(pronunciation_dict[word.upper()])`
Upgrade
Version history
1.1.3latest on PyPI · released Jan 3, 2026
Audit
Dependencies
pythonrequiredRequired Python version range.
Agent activity
57 hits · last 30 days
node
52
OpenAI (training)
1
Resources
cmudict — pip install cmudict · libregistry