Skip to content

Commit

Permalink
replace cn2an with WeTextProcessing for text normalization (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
faceair authored Dec 22, 2023
1 parent e7e7a8c commit 597970a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions fish_speech/text/chinese.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import re

import cn2an
import jieba.posseg as psg
from pypinyin import Style, lazy_pinyin
from tn.chinese.normalizer import Normalizer

from fish_speech.text.symbols import punctuation
from fish_speech.text.tone_sandhi import ToneSandhi
Expand All @@ -16,7 +16,7 @@
for line in open(OPENCPOP_DICT_PATH).readlines()
}


normalizer = Normalizer()
tone_modifier = ToneSandhi()


Expand Down Expand Up @@ -123,10 +123,7 @@ def _g2p(segments):


def text_normalize(text):
numbers = re.findall(r"\d+(?:\.?\d+)?", text)
for number in numbers:
text = text.replace(number, cn2an.an2cn(number), 1)
return text
return normalizer.normalize(text)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies = [
"vector-quantize-pytorch>=1.10.0",
"rich>=13.5.3",
"gradio>=4.0.0",
"cn2an>=0.5.22",
"pypinyin>=0.49.0",
"jieba>=0.42.1",
"g2p-en>=2.1.0",
Expand All @@ -34,6 +33,7 @@ dependencies = [
"kui>=1.6.0",
"zibai-server>=0.9.0",
"loguru>=0.6.0",
"WeTextProcessing>=0.1.10",
]

[project.optional-dependencies]
Expand Down

0 comments on commit 597970a

Please sign in to comment.