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 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!
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

a
aɚ̯
ai̯
au̯
e
ei̯
f
h
i
j
k
kʰ
l
m
n
o
ou̯
p
pʰ
s
t
ts
tsʰ
tɕ
tɕʰ
tʰ
u
w
x
y
ŋ
ɕ
ə
ɚ
ɛ
ɤ
ɥ
ɹ̩
ɻ
ɻ̩
ʂ
ʈʂ
ʈʂʰ
ʊ
z̩
ʐ
ʐ̩

Vowels and diphthongs contain one of these tones:

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

Dependencies

  • ordered-set >= 4.1.0
  • pypinyin = ">=0.47.1, <0.48"

License

MIT License

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).

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.1.tar.gz (22.7 kB view hashes)

Uploaded Source

Built Distribution

pinyin_to_ipa-0.0.1-py3-none-any.whl (13.8 kB view hashes)

Uploaded Python 3

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