Skip to main content

pinyin-to-ipa

CI codecov PyPI Python versions License: MIT
PyPI Downloads Hugging Face 🤗 DOI

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.

Screenshot Hugging Face

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

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. (2026). pinyin-to-ipa (Version 1.0.1) [Computer software]. https://doi.org/10.5281/zenodo.7524690

Release files for pinyin-to-ipa 1.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 pinyin-to-ipa 1.0.1
File Size Uploaded
pinyin_to_ipa-1.0.1.tar.gz 32.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pinyin-to-ipa 1.0.1
File Interpreter ABI Platform
pinyin_to_ipa-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.3 kB

Release files / pinyin_to_ipa-1.0.1.tar.gz

Download URL pinyin_to_ipa-1.0.1.tar.gz
Size 32.9 kB
Tags Source
SHA-256 checksum
How to use checksums
25ab0b0b1a6a75cb8bb94a6458a3fa6ac0bb8ba1aa608e7d2e99b32b76145b5f
BLAKE2b-256 checksum
How to use checksums
696c1bef02002d89ad1f07233fca162bbe60134c28134f713d9480684cef92f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.11

Release files / pinyin_to_ipa-1.0.1-py3-none-any.whl

Download URL pinyin_to_ipa-1.0.1-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcf41691e465e68e52ce5a05e01762f9c8b4ac4c146b1ee6867bc034b7fbf502
BLAKE2b-256 checksum
How to use checksums
a6f7e3a8942f8f0a37f10e60050bc7626feff17c240e54cbbeb64d166475cc07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

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