mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2026-11-17 18:43:37 +08:00
Merge ad0e0e758fb4b8418c6bd2792eb37ae5c4cb2e73 into 6d51ffceafbf240145619af4c92408a6e54b7924
This commit is contained in:
commit
592adc8cfc
@ -75,7 +75,8 @@ def replace_percentage(match) -> str:
|
||||
|
||||
# 整数表达式
|
||||
# 带负号的整数 -10
|
||||
RE_INTEGER = re.compile(r"(-)" r"(\d+)")
|
||||
# 不匹配负小数(如 -1.5)的整数部分
|
||||
RE_INTEGER = re.compile(r"(-)" r"(\d+)" r"(?!\.?\d)")
|
||||
|
||||
|
||||
def replace_negative_num(match) -> str:
|
||||
|
||||
26
test_zh_normalization_num.py
Normal file
26
test_zh_normalization_num.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Regressions for reading numbers in Chinese text normalization, without loading any model."""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path[:0] = [str(Path(__file__).resolve().parent / "GPT_SoVITS")]
|
||||
from text.zh_normalization.text_normlization import TextNormalizer # noqa: E402
|
||||
|
||||
|
||||
class NegativeNumberTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.normalizer = TextNormalizer()
|
||||
|
||||
def test_negative_decimals(self):
|
||||
self.assertEqual(self.normalizer.normalize_sentence("-1.5"), "负一点五")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("-0.5"), "负零点五")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("余额为-3.75元"), "余额为负三点七五元")
|
||||
|
||||
def test_negative_integers(self):
|
||||
self.assertEqual(self.normalizer.normalize_sentence("-10"), "负十")
|
||||
self.assertEqual(self.normalizer.normalize_sentence("温度是-1。"), "温度是负一。")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
x
Reference in New Issue
Block a user