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.1.tar.gz (923.9 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.1-py3-none-any.whl (925.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyenglish2pinyin-0.1.1.tar.gz
  • Upload date:
  • Size: 923.9 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.1.tar.gz
Algorithm Hash digest
SHA256 984ba2dd0d5782c0bd71c5e310dd5a18a30a0cdd656c259e166c88a213a69c94
MD5 cd264c06aba43e995be69e49aaea48de
BLAKE2b-256 2eb4f2ee9b59e133a09dfaa58640dd2d3d314f7b80c0f0ada07b7ed31f660956

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyenglish2pinyin-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9256771ebc97bf0c1fbd58b040eb3f80a327853316a572c3c47c96be129ec30b
MD5 605bc9c2cf0734c1a358a00ed4265752
BLAKE2b-256 60ab391057833b1c5fb54dfc9c7035e9b76b278bd7d996fdae3b97deddd2ed15

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