Metadata-Version: 2.4
Name: pinyin-to-ipa
Version: 1.0.1
Summary: A Python library, web application, and command-line tool for transcribing Pinyin to IPA. Tone markers are attached to the vowel of each syllable.
Author: Stefan Taubert
Maintainer: Stefan Taubert
License: MIT License
        
        Copyright (c) 2026 Stefan Taubert
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/stefantaubert/pinyin-to-ipa
Project-URL: Issues, https://github.com/stefantaubert/pinyin-to-ipa/issues
Keywords: Chinese,Mandarin,Pinyin,IPA,Phonetics,Phonology,Tone,Transcription,Language,Linguistics,Speech,Romanization,Language Learning,Natural Language Processing,Grapheme-to-Phoneme
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Operating System :: POSIX :: BSD
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Multimedia :: Sound/Audio
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Classifier: Topic :: Multimedia :: Sound/Audio :: Sound Synthesis
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Environment :: Console
Classifier: Environment :: Web Environment
Requires-Python: <3.15,>=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ordered-set>=4.1.0
Requires-Dist: pypinyin>=0.54
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: pytest-xdist; extra == "dev"
Requires-Dist: tox; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: rope; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: app
Requires-Dist: gradio; extra == "app"
Dynamic: license-file

# pinyin-to-ipa

[![CI](https://github.com/stefantaubert/pinyin-to-ipa/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stefantaubert/pinyin-to-ipa/actions/workflows/ci.yml)
[![codecov](https://codecov.io/github/stefantaubert/pinyin-to-ipa/branch/master/graph/badge.svg?token=DZ8LB2Q5I0)](https://codecov.io/github/stefantaubert/pinyin-to-ipa)
[![PyPI](https://img.shields.io/pypi/v/pinyin-to-ipa.svg)](https://pypi.python.org/pypi/pinyin-to-ipa)
[![Python versions](https://img.shields.io/pypi/pyversions/pinyin-to-ipa.svg)](https://pypi.python.org/pypi/pinyin-to-ipa)
[![License: MIT](https://img.shields.io/github/license/stefantaubert/pinyin-to-ipa.svg)](https://github.com/stefantaubert/pinyin-to-ipa/blob/master/LICENSE) \
[![PyPI Downloads](https://img.shields.io/pypi/dm/pinyin-to-ipa.svg?label=PyPI%20downloads)](https://pypi.org/project/pinyin-to-ipa)
[![Hugging Face 🤗](https://img.shields.io/badge/%20%F0%9F%A4%97_Hugging_Face-pinyin--to--ipa-blue.svg)](https://huggingface.co/spaces/stefantaubert/pinyin-to-ipa)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7524690.svg)](https://doi.org/10.5281/zenodo.7524690)

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

```sh
pip install pinyin-to-ipa[app] --user
```

### Usage as library

```py
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:

```sh
$ pinyin-to-ipa-app
```

Or visit [🤗 Hugging Face](https://huggingface.co/spaces/stefantaubert/pinyin-to-ipa) for a live demo.

<a href="https://huggingface.co/spaces/stefantaubert/pinyin-to-ipa">
<img src="https://github.com/stefantaubert/pinyin-to-ipa/raw/master/img/gui.png" alt="Screenshot Hugging Face" style="max-width: 600px; width: 100%"/>
</a>

## Usage as CLI

```sh
$ pinyin-to-ipa-cli
```

```txt
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

```sh
$ 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

```txt
a ɛ e ə ɚ ɤ i o ɔ u ʊ y 
```

### Diphthongs

```txt
ai̯ au̯ aɚ̯¹ ei̯ ou̯ 
```

¹ These phonemes are not included if only the first transcription is used.

### Consonants

```txt
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:

```txt
˥ (first tone)
˧˥ (second tone)
˧˩˧ (third tone)
˥˩ (fourth tone)
(none)
```

## References

- [https://en.wikipedia.org/wiki/Help:IPA/Mandarin](https://en.wikipedia.org/wiki/Help:IPA/Mandarin)
- [https://en.wikipedia.org/wiki/Standard_Chinese_phonology](https://en.wikipedia.org/wiki/Standard_Chinese_phonology)
- [https://en.wikipedia.org/wiki/Pinyin](https://en.wikipedia.org/wiki/Pinyin)
- [https://de.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](https://github.com/mozillazg/python-pinyin)
- 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*).

```txt
Taubert, S. (2026). pinyin-to-ipa (Version 1.0.1) [Computer software]. https://doi.org/10.5281/zenodo.7524690
```
