Skip to content

Commit

Permalink
fix a bug in Mandarin pypinyin_g2p_phone
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiGodHorse committed Mar 25, 2022
1 parent 253eb17 commit 50269e8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions espnet2/text/phoneme_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ 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),
# When using the new pypinyin, the previous code will drop the finals
get_finals(phone[0][:-1], strict=True) + phone[0][-1] if phone[0][-1].isdigit() else get_finals(phone[0], strict=True),
]
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

0 comments on commit 50269e8

Please sign in to comment.