|
@@ -1,23 +1,13 @@
|
|
|
import os
|
|
import os
|
|
|
import re
|
|
import re
|
|
|
|
|
|
|
|
|
|
+import cn2an
|
|
|
import jieba.posseg as psg
|
|
import jieba.posseg as psg
|
|
|
-from loguru import logger
|
|
|
|
|
from pypinyin import Style, lazy_pinyin
|
|
from pypinyin import Style, lazy_pinyin
|
|
|
|
|
|
|
|
from fish_speech.text.symbols import punctuation
|
|
from fish_speech.text.symbols import punctuation
|
|
|
from fish_speech.text.tone_sandhi import ToneSandhi
|
|
from fish_speech.text.tone_sandhi import ToneSandhi
|
|
|
|
|
|
|
|
-try:
|
|
|
|
|
- from tn.chinese.normalizer import Normalizer
|
|
|
|
|
-
|
|
|
|
|
- normalizer = Normalizer().normalize
|
|
|
|
|
-except ImportError:
|
|
|
|
|
- import cn2an
|
|
|
|
|
-
|
|
|
|
|
- logger.warning("tn.chinese.normalizer not found, use cn2an normalizer")
|
|
|
|
|
- normalizer = lambda x: cn2an.transform(x, "an2cn")
|
|
|
|
|
-
|
|
|
|
|
current_file_path = os.path.dirname(__file__)
|
|
current_file_path = os.path.dirname(__file__)
|
|
|
OPENCPOP_DICT_PATH = os.path.join(current_file_path, "opencpop-strict.txt")
|
|
OPENCPOP_DICT_PATH = os.path.join(current_file_path, "opencpop-strict.txt")
|
|
|
|
|
|
|
@@ -132,7 +122,7 @@ def _g2p(segments):
|
|
|
|
|
|
|
|
|
|
|
|
|
def text_normalize(text):
|
|
def text_normalize(text):
|
|
|
- return normalizer(text)
|
|
|
|
|
|
|
+ return cn2an.transform(text, "an2cn")
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|