Skip to content

Commit

Permalink
add double byte char for zh normalization (#2661)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-95 committed Nov 21, 2022
1 parent 94a487b commit 1c3d2cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions paddlespeech/t2s/frontend/zh_normalization/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
# 全角半角转换
# 英文字符全角 -> 半角映射表 (num: 52)
F2H_ASCII_LETTERS = {
chr(ord(char) + 65248): char
ord(char) + 65248: ord(char)
for char in string.ascii_letters
}

# 英文字符半角 -> 全角映射表
H2F_ASCII_LETTERS = {value: key for key, value in F2H_ASCII_LETTERS.items()}

# 数字字符全角 -> 半角映射表 (num: 10)
F2H_DIGITS = {chr(ord(char) + 65248): char for char in string.digits}
F2H_DIGITS = {ord(char) + 65248: ord(char) for char in string.digits}
# 数字字符半角 -> 全角映射表
H2F_DIGITS = {value: key for key, value in F2H_DIGITS.items()}

# 标点符号全角 -> 半角映射表 (num: 32)
F2H_PUNCTUATIONS = {chr(ord(char) + 65248): char for char in string.punctuation}
F2H_PUNCTUATIONS = {ord(char) + 65248: ord(char) for char in string.punctuation}
# 标点符号半角 -> 全角映射表
H2F_PUNCTUATIONS = {value: key for key, value in F2H_PUNCTUATIONS.items()}

Expand Down
11 changes: 11 additions & 0 deletions paddlespeech/t2s/frontend/zh_normalization/text_normlization.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ def _split(self, text: str, lang="zh") -> List[str]:
def _post_replace(self, sentence: str) -> str:
sentence = sentence.replace('/', '每')
sentence = sentence.replace('~', '至')
sentence = sentence.replace('~', '至')
sentence = sentence.replace('①', '一')
sentence = sentence.replace('②', '二')
sentence = sentence.replace('③', '三')
sentence = sentence.replace('④', '四')
sentence = sentence.replace('⑤', '五')
sentence = sentence.replace('⑥', '六')
sentence = sentence.replace('⑦', '七')
sentence = sentence.replace('⑧', '八')
sentence = sentence.replace('⑨', '九')
sentence = sentence.replace('⑩', '十')

return sentence

Expand Down

0 comments on commit 1c3d2cb

Please sign in to comment.