Download python/cn_frontend/symbols.py from AXERA-TECH/Inflect-Micro-v2-zh: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/AXERA-TECH/Inflect-Micro-v2-zh/resolve/main/python/cn_frontend/symbols.py
- Command line
-
hf download hf://AXERA-TECH/Inflect-Micro-v2-zh/python/cn_frontend/symbols.py
-
curl -L -o symbols.py https://huggingface.co/AXERA-TECH/Inflect-Micro-v2-zh/resolve/main/python/cn_frontend/symbols.py
536 Bytes
| """Chinese pinyin character-level symbol set.""" | |
| _pad = "_" | |
| # All possible pinyin characters (a-z) plus tone digits (1-5) | |
| _pinyin_chars = "abcdefghijklmnopqrstuvwxyz12345 " | |
| # Chinese punctuation | |
| _punct = ",。!?;:、…—""''()《》·" | |
| symbols = [_pad] + list(_pinyin_chars) + list(_punct) | |
| _symbol_to_id = {s: i for i, s in enumerate(symbols)} | |
| PAD_ID = 0 | |
| SPACE_ID = _symbol_to_id.get(" ", len(symbols)) | |
| def get_phoneme_ids(phonemes: str) -> list[int]: | |
| return [_symbol_to_id.get(p, PAD_ID) for p in phonemes] | |