https://github.com/travisgk/colortones
A Python script to color Chinese syllables by their tones in the form of an HTML table.
https://github.com/travisgk/colortones
chinese css html-generator html5 international-phonetic-alphabet language-learning language-tones linguistics mandarin phonemes phonetics pinyin tones zhuyin
Last synced: 3 months ago
JSON representation
A Python script to color Chinese syllables by their tones in the form of an HTML table.
- Host: GitHub
- URL: https://github.com/travisgk/colortones
- Owner: travisgk
- License: mit
- Created: 2024-04-18T02:35:58.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-04T18:08:47.000Z (7 months ago)
- Last Synced: 2024-11-04T18:38:00.053Z (7 months ago)
- Topics: chinese, css, html-generator, html5, international-phonetic-alphabet, language-learning, language-tones, linguistics, mandarin, phonemes, phonetics, pinyin, tones, zhuyin
- Language: Python
- Homepage:
- Size: 2.39 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# colortones
A Python script that colors Chinese characters to match their spoken tone.
This tool provides other transcriptions into zhuyin, pinyin, and the IPA as well.
# Setup
```
pip install pypinyin jieba
```
# Example
```
import colortones# processes the text.
chinese = "老板想买哪种水果?我听不懂。不要打扰我。"
paragraph = colortones.process_text(chinese)# loads a color scheme.
scheme = colortones.load_color_scheme("default")# prints colored text to the console.
print(paragraph.to_color_str("hanzi", color_scheme=scheme))
print(paragraph.to_color_str("pinyin", color_scheme=scheme))
print(paragraph.to_color_str("ipa-root", color_scheme=scheme))
print(paragraph.to_color_str("zhuyin-root", color_scheme=scheme))
```