Code Monkey home page Code Monkey logo

pinyin-to-ipa's Introduction

pinyin-to-ipa

PyPI PyPI Hugging Face 🤗 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 as web app

Visit 🤗 Hugging Face for a live demo.

Screenshot Hugging Face

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

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

pinyin-to-ipa's People

Contributors

stefantaubert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pinyin-to-ipa's Issues

Add support for erhua

Hey, could you add support for erhua. Combinations such as 事儿 = shìr​ are not handled. Even in standard Chinese (news etc.), erhua is often heard.

Wrong IPA for yo1

哟 = yo1 = /jɔ˥/

>>> pinyin_to_ipa("yo1")
OrderedSet([('w', 'o˥')])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.