Skip to content

A Python converter for Chinese Pinyin and Shengyun (initials and finals)

License

Notifications You must be signed in to change notification settings

yuyq96/pyshengyun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyShengyun (🇨🇳)

A converter for Chinese Pinyin and Shengyun (initials and finals) in Python and can be utilized in automatic speech recognition or text-to-speech synthesis.

Installation

$ git clone https://github.com/yuyq96/pyshengyun

Usage

>>> from pyshengyun import *
>>> tone
['1', '2', '3', '4', '5']
>>> letter
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
>>> initials  # equivalent to 'sheng'
['b', 'p', 'm', 'f', 'd', 't', 'n', 'l', 'g', 'k', 'h', 'j', 'q', 'x', 'zh', 'ch', 'sh', 'r', 'z', 'c', 's']
>>> finals  # equivalent to 'yun'
['a', 'o', 'e', 'ai', 'ei', 'ao', 'ou', 'an', 'en', 'ang', 'eng', 'ong', 'i', 'ia', 'ie', 'iao', 'iou', 'ian', 'in', 'iang', 'ing', 'iong', 'u', 'ua', 'uo', 'uai', 'uei', 'uan', 'uen', 'uang', 'ueng', 'v', 've', 'van', 'vn']
>>> initials_finals  # equivalent to 'shengyun'
['b', 'p', 'm', 'f', 'd', 't', 'n', 'l', 'g', 'k', 'h', 'j', 'q', 'x', 'zh', 'ch', 'sh', 'r', 'z', 'c', 's', 'a', 'o', 'e', 'ai', 'ei', 'ao', 'ou', 'an', 'en', 'ang', 'eng', 'ong', 'i', 'ia', 'ie', 'iao', 'iou', 'ian', 'in', 'iang', 'ing', 'iong', 'u', 'ua', 'uo', 'uai', 'uei', 'uan', 'uen', 'uang', 'ueng', 'v', 've', 'van', 'vn']
>>> list(pinyin_to_initials_finals('hua yuan'))  # 'pinyin_to_initials_finals' is equivalent to 'pinyin_to_shengyun' and it returns a generator
[['h', 'ua'], ['van']]
>>> list(initials_finals_to_pinyin('hua van'))  # 'initials_finals_to_pinyin' is equivalent to 'shengyun_to_pinyin' and it returns a generator
['hua', 'yuan']

Related Projects

  • pypinyin: A Python tool for converting Chinese character to Pinyin.

Releases

No releases published

Packages

No packages published

Languages