Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporated "Xiandai Hanyu Cidian" pinyin data to correct inaccuracies in the generation of pinyin for Chinese characters with multiple pronunciations. #3652

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions TTS/tts/utils/text/chinese_mandarin/phonemizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import pypinyin

from .pinyinToPhonemes import PINYIN_DICT
from pypinyin_dict.pinyin_data import kxhc1983


def enhance_dict():
kxhc1983.load()

def _chinese_character_to_pinyin(text: str) -> List[str]:
pinyins = pypinyin.pinyin(text, style=pypinyin.Style.TONE3, heteronym=False, neutral_tone_with_five=True)
pinyins_flat_list = [item for sublist in pinyins for item in sublist]
Expand Down
3 changes: 2 additions & 1 deletion TTS/tts/utils/text/phonemizers/zh_cn_phonemizer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict

from TTS.tts.utils.text.chinese_mandarin.phonemizer import chinese_text_to_phonemes
from TTS.tts.utils.text.chinese_mandarin.phonemizer import chinese_text_to_phonemes, enhance_dict
from TTS.tts.utils.text.phonemizers.base import BasePhonemizer

_DEF_ZH_PUNCS = "、.,[]()?!〽~『』「」【】"
Expand All @@ -27,6 +27,7 @@ class ZH_CN_Phonemizer(BasePhonemizer):

def __init__(self, punctuations=_DEF_ZH_PUNCS, keep_puncs=False, **kwargs): # pylint: disable=unused-argument
super().__init__(self.language, punctuations=punctuations, keep_puncs=keep_puncs)
enhance_dict()

@staticmethod
def name():
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ coqpit>=0.0.16
# chinese g2p deps
jieba
pypinyin
pypinyin-dict
# korean
hangul_romanize
# gruut+supported langs
Expand Down
Loading