A Python library, web application, and command-line tool for transcribing Pinyin to IPA. Tone markers are attached to the vowel of each syllable.
Project description
pinyin-to-ipa
A Python library, web application, and command-line tool for transcribing Pinyin to IPA.
Tone markers are attached to the vowel of each syllable.
Getting started
Installation
pip install pinyin-to-ipa[app] --user
Usage as library
from pinyin_to_ipa import pinyin_to_ipa
print(pinyin_to_ipa("hang4"))
# OrderedSet([('x', 'a˥˩', 'ŋ'), ('h', 'a˥˩', 'ŋ')])
print(pinyin_to_ipa("ng"))
# OrderedSet([('ŋ',)])
Usage as web app
Start the web app from the command-line:
$ pinyin-to-ipa-app
Or visit 🤗 Hugging Face for a live demo.
Usage as CLI
$ pinyin-to-ipa-cli
usage: pinyin-to-ipa-cli [-h] [-v] [--sep SEP] [--first] PINYIN
Command-line interface (CLI) to transcribe pinyin to IPA.
positional arguments:
PINYIN pinyin
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--sep SEP separator between phonemes (default: )
--first return only first result (default: False)
Example
$ pinyin-to-ipa-cli "pang1"
pʰa˥ŋ
$ pinyin-to-ipa-cli "pang2"
pʰa˧˥ŋ
$ pinyin-to-ipa-cli "pang3"
pʰa˧˩˧ŋ
$ pinyin-to-ipa-cli "pang4"
pʰa˥˩ŋ
$ pinyin-to-ipa-cli "pang5"
pʰaŋ
$ pinyin-to-ipa-cli "pang"
pʰaŋ
$ pinyin-to-ipa-cli "hàng"
xa˥˩ŋ
ha˥˩ŋ
$ pinyin-to-ipa-cli "hàng" --first
xa˥˩ŋ
$ pinyin-to-ipa-cli "hng"
hŋ
$ pinyin-to-ipa-cli "test"
No IPA transcription available!
Phoneme set
Vowels
a ɛ e ə ɚ ɤ i o ɔ u ʊ y
Diphthongs
ai̯ au̯ aɚ̯¹ ei̯ ou̯
¹ These phonemes are not included if only the first transcription is used.
Consonants
f h¹ j k kʰ l m n ŋ p pʰ ɹ̩² ɻ² ɻ̩²
s ʂ t tʰ ts tsʰ tɕ tɕʰ ʈʂ ʈʂʰ
w x ɕ ɥ z̩¹² ʐ¹² ʐ̩¹²
² These consonants contain also tones.
Tones
Vowels and diphthongs contain one of these tones:
˥ (first tone)
˧˥ (second tone)
˧˩˧ (third tone)
˥˩ (fourth tone)
(none)
References
- https://en.wikipedia.org/wiki/Help:IPA/Mandarin
- https://en.wikipedia.org/wiki/Standard_Chinese_phonology
- https://en.wikipedia.org/wiki/Pinyin
- https://de.wikipedia.org/wiki/Pinyin
- Duanmu, San. 2007. The Phonology of Standard Chinese. 2nd ed. Oxford ; New York: Oxford University Press.
- Lin, Yen-Hwei. 2007. The Sounds of Chinese. Cambridge, UK ; New York: Cambridge University Press.
Acknowledgments
- pypinyin
- Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – Project-ID 416228727 – CRC 1410
Citation
If you want to cite this repo, you can use this BibTeX-entry generated by GitHub (see About => Cite this repository).
Taubert, S. (2025). pinyin-to-ipa (Version 1.0.0) [Computer software]. https://doi.org/10.5281/zenodo.15229718
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pinyin_to_ipa-1.0.0.tar.gz
.
File metadata
- Download URL: pinyin_to_ipa-1.0.0.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
97e4199220a6ff4eed2e89aa00124c977db91826f93ed743c74dbacd8544e736
|
|
MD5 |
e7200574b49caccc3310a0574765242f
|
|
BLAKE2b-256 |
bfad5b2d5d0b2f9e4ffff4ada81587d636ca6918babd51c335ffbf5bedf7d906
|
File details
Details for the file pinyin_to_ipa-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pinyin_to_ipa-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4fad93242eeebe8817af99da2a4e5f5da16e10d93336991d36839ebc356c04a9
|
|
MD5 |
5c5e6c7a465eefae510b48bc0c9ae227
|
|
BLAKE2b-256 |
d36abad4d572d08ccd1d3b7e1ab4a2b7aa8ea46db22c7b670820bc4a341dd662
|