Skip to main content

English to IPA (eng_to_ipa)

This Python program utilizes the Carnegie-Mellon University Pronouncing Dictionary to convert English text into the International Phonetic Alphabet.

The convert function is used to take English text and convert it to IPA, like so:

>>> import eng_to_ipa as ipa
>>> ipa.convert("The quick brown fox jumped over the lazy dog.")
'ðə kwɪk braʊn fɑks ʤəmpt ˈoʊvər ðə ˈleɪzi dɔg.'

Note that words that cannot be found in the CMU dictionary are simply reprinted with an asterisk.

convert parameters

  • text : string - The input string of English text to be converted to IPA notation.

  • keep_punct : boolean, optional (default=True) - Determines whether or not the punctuation marks from the input string should be retained or not.

  • retrieve_all : boolean, optional (default=False) - Given that some words might have more than one transcription, this parameter determines whether or not a list of all possible combinations of transcriptions should be returned (True) or just the string of one transcription (False).

  • stress_marks : string, optional (default='both') - Determines whether or not the primary and secondary stress markings (ˈ, ˌ) should be retained. Understood arguments are:

    • "primary" - retains primary stress only
    • "secondary" - retains secondary stress only
    • "both" - to keep both primary and secondary stress markers.
  • mode : string, optional (default='sql') - Accepts "sql" or "json", depending on which version of the database you'd like to use. As another option for JSON users, simply use the function jonvert instead of convert.

The ipa_list function returns a list of each word as a list of all its possible transcriptions. It has all the same optional stress_marks and keep_punct parameters as convert.

>>> ipa.ipa_list("The record was expensive.")
[['ði', 'ðə'], ['rəˈkɔrd', 'rɪˈkɔrd', 'ˈrɛkərd'], ['wɑz'], ['ɪkˈspɛnsɪv.']]

The isin_cmu function takes a word (or list of words) and checks if it is in the CMU pronouncing dictionary (returns True or False). If a list of words is provided, then True will only be returned if every provided word is in the dictionary.

>>> ipa.isin_cmu("The dentist opened a new practice.")
True
>>> ipa.isin_cmu("emoji")
False

The get_rhymes function returns a list of rhymes for a word or set of words.

>>> ipa.get_rhymes("rhyming function")
[['climbing', 'diming', 'liming', 'priming', 'timing'], ['compunction', 'conjunction', 'dysfunction', 'injunction', 'junction', 'malfunction']]

Use the jhymes function instead to force usage of the JSON database.

The syllable_count function returns an integer, corresponding to the number of syllables in a word. Returns a list of syllable counts if more than one word is provided in the input string.

>>> ipa.syllable_count("computer programming")
[3, 3]

For another Python package that offers support for rhyming and syllable counts (as well as other cool things), see pronouncingpy.

Note: I'd like to make this project easily available/installable from pip, but I don't know how. Looking for help!

Release

version: 0.0.1

How to release

pip install setuptools wheel twine
python setup.py sdist
python -m twine upload --repository  testpypi dist/*
python -m twine upload --repository  pypi dist/*
rm -rf dist *.egg-info MANIFEST

Metadata

Release files for eng-to-ipa 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eng-to-ipa 0.0.1
File Size Uploaded Provenance Actions
eng_to_ipa-0.0.1.tar.gz 2.8 MB Without provenance Details for eng_to_ipa-0.0.1.tar.gz

Release files / eng_to_ipa-0.0.1.tar.gz

Download URL eng_to_ipa-0.0.1.tar.gz
Size 2.8 MB
Tags Source
SHA-256 checksum
How to use checksums
1d2e008a6fd3676cbe902d08cc8c8f228d13e476a514fcc8442c3d43b88fc9e2
BLAKE2b-256 checksum
How to use checksums
fdf6c36ccd1b8cf5ec286f6f516b135f30953db49c0f618f1eedc455afd890d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9

Security for eng-to-ipa 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page