Skip to main content

Convert English words to numbered Pinyin using CMUdict IPA.

Project description

PYENGLISH2PINYIN

English | 中文 | Français

Convert English words to numbered Pinyin(mandarin/chinese phonetic system) through CMUdict IPA.

Input and Output Examples

English word to Pinyin (12 verified examples)

English Word Pinyin Output
record ruo5 kao1 r5 de5
communication ka5 mu5 yu4 na5 kui1 sha5 en5
in yi5 en5
securing xi5 ke5 yu1 rui5 eng5
prime po5 ruo1 mu5
foreign fan1 ruo5 en5
aldinger ao1 ao5 di5 eng5 r5
engleman yi1 eng5 a5 ao5 ma5 en5
legacy lai1 ga5 xi5
blotting bo5 la1 ti5 eng5
english yi1 eng5 ge5 li5 shi5
banana ba5 nai1 na5

IPA to Pinyin

IPA Input Pinyin Output
AE2 P L AH0 K EY1 SH AH0 N ai4 po5 la5 kui1 sha5 en5
S IH0 K Y UH1 R IH0 NG xi5 ke5 yu1 rui5 eng5
L EH1 G AH0 S IY0 lai1 ga5 xi5

This is especially helpful when training FastSpeech2 speech synthesis for mixed Chinese and English text, because it reduces dataset preparation effort for text normalization and phoneme alignment while keeping pronunciation labels consistent.

Install

pip install pyenglish2pinyin

Usage

from english2pinyin import english2ipa, english2pinyin, ipa2pinyin

print(english2ipa("application"))
# AE2 P L AH0 K EY1 SH AH0 N

print(english2pinyin("application"))
# ai4 po5 la5 kui1 sha5 en5

print(ipa2pinyin("S IH0 K Y UH1 R IH0 NG"))
# xi5 ke5 yu1 rui5 eng5

API

  • english2ipa(word, dict_path=None) -> str | None
  • english2pinyin(word, dict_path=None, throw_if_missing=False) -> str
  • ipa2pinyin(ipa_text) -> str

Development

pip install -e .[dev]
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyenglish2pinyin-0.1.2.tar.gz (927.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyenglish2pinyin-0.1.2-py3-none-any.whl (949.8 kB view details)

Uploaded Python 3

File details

Details for the file pyenglish2pinyin-0.1.2.tar.gz.

File metadata

  • Download URL: pyenglish2pinyin-0.1.2.tar.gz
  • Upload date:
  • Size: 927.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for pyenglish2pinyin-0.1.2.tar.gz
Algorithm Hash digest
SHA256 08018d3328762e8cf6b416767ac41f69c82168fca4bda13616de9bda9c37cef1
MD5 6123c463f6821ad82defa04691b26abe
BLAKE2b-256 1a5dd2d7843915b23599873666b2242a42a850a7e4e087b27e03e45d59869525

See more details on using hashes here.

File details

Details for the file pyenglish2pinyin-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyenglish2pinyin-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df3575b570d391a5c3c570d05ae650a8d5327f330492d1d03c88fdd559f5779c
MD5 c39fb800693686af7c0554d5d3c06804
BLAKE2b-256 31609bb2ab1d9366cece732f20fd3898ecf6bfd82ffb3d6f701ee1f8942655c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page