Skip to content

Commit

Permalink
Merge pull request espnet#4206 from WeiGodHorse/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kan-bayashi authored May 11, 2022
2 parents 2dde773 + f7b3905 commit dd24d7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions espnet2/text/phoneme_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,14 @@ def pypinyin_g2p_phone(text) -> List[str]:
for phone in pinyin(text, style=Style.TONE3)
for p in [
get_initials(phone[0], strict=True),
get_finals(phone[0], strict=True),
get_finals(phone[0][:-1], strict=True) + phone[0][-1]
if phone[0][-1].isdigit()
else get_finals(phone[0], strict=True)
if phone[0][-1].isalnum()
else phone[0],
]
if len(p) != 0
# Remove the case of individual tones as a phoneme
if len(p) != 0 and not p.isdigit()
]
return phones

Expand Down
2 changes: 1 addition & 1 deletion test/espnet2/text/test_phoneme_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_text2tokens(phoneme_tokenizer: PhonemeTokenizer):
"ei2",
"uai4",
"s",
"un1",
"uen1",
"uan2",
"h",
"ua2",
Expand Down

0 comments on commit dd24d7d

Please sign in to comment.