"""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]