Skip to main content

Command-line interface (CLI) and Python library to transcribe pinyin to IPA.

Project description

pinyin-to-ipa

PyPI PyPI MIT PyPI PyPI PyPI DOI

Command-line interface (CLI) and Python library to transcribe pinyin to IPA. The tones are attached to the vowel of the syllable.

Installation

pip install pinyin-to-ipa --user

Usage

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!

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([('ŋ',)])

Phoneme Set

Vowels:

a
ɛ
e
ə
ɚ
ɤ
i
o
u
ʊ
y

Diphthongs:

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

Consonants:

f
h¹
j
k
kʰ
l
m
n
p
pʰ
ɹ̩²
ɻ²
ɻ̩²
s
t
ts
tsʰ
tɕ
tɕʰ
tʰ
w
x
ŋ
ɕ
ɥ
ʂ
ʈʂ
ʈʂʰ
z̩¹²
ʐ¹²
ʐ̩¹²

Vowels and diphthongs contain one of these tones:

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

¹ These phonemes are not included if only the first transcription is used.
² These consonants contain also tones.

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

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

pinyin-to-ipa-0.0.2.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

pinyin_to_ipa-0.0.2-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file pinyin-to-ipa-0.0.2.tar.gz.

File metadata

  • Download URL: pinyin-to-ipa-0.0.2.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pinyin-to-ipa-0.0.2.tar.gz
Algorithm Hash digest
SHA256 145342758e971efa19a5d5b07f911efe462bca6ceb4bf8480602658c2b4d4fd7
MD5 4690bca9c977367aa9b3a45145510160
BLAKE2b-256 4fcef4532888ea269ba0d8f70f66b5cf0217bdb615bb600891a0ab0c4ed9dead

See more details on using hashes here.

File details

Details for the file pinyin_to_ipa-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pinyin_to_ipa-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a24382fcd7f40dcd8b3456553e3212c8640934fbbfcb32e2f29f5d02cb0c860
MD5 a23d35f1f87189f9aceb283b82dd5d41
BLAKE2b-256 c0aebd46bd56a49b904fd7d1f10ee0b622912ec7c8b6f755ee67a308e8d76c5b

See more details on using hashes here.

Supported by

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