mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-08-19 16:29:47 +08:00
add version num2str
This commit is contained in:
parent
d90ee93c23
commit
715e60a114
@ -256,6 +256,24 @@ def replace_to_range(match) -> str:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
RE_VERSION_NUM = re.compile(r"((\d+)(\.\d+)(\.\d+)?(\.\d+)+)")
|
||||||
|
def replace_vrsion_num(match) -> str:
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
match (re.Match)
|
||||||
|
Returns:
|
||||||
|
str
|
||||||
|
"""
|
||||||
|
result = ""
|
||||||
|
for c in match.group(1):
|
||||||
|
if c == ".":
|
||||||
|
result += "点"
|
||||||
|
else:
|
||||||
|
result += num2str(c)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _get_value(value_string: str, use_zero: bool = True) -> List[str]:
|
def _get_value(value_string: str, use_zero: bool = True) -> List[str]:
|
||||||
stripped = value_string.lstrip("0")
|
stripped = value_string.lstrip("0")
|
||||||
if len(stripped) == 0:
|
if len(stripped) == 0:
|
||||||
|
@ -25,6 +25,7 @@ from .chronology import replace_time
|
|||||||
from .constants import F2H_ASCII_LETTERS
|
from .constants import F2H_ASCII_LETTERS
|
||||||
from .constants import F2H_DIGITS
|
from .constants import F2H_DIGITS
|
||||||
from .constants import F2H_SPACE
|
from .constants import F2H_SPACE
|
||||||
|
from .num import RE_VERSION_NUM
|
||||||
from .num import RE_DECIMAL_NUM
|
from .num import RE_DECIMAL_NUM
|
||||||
from .num import RE_DEFAULT_NUM
|
from .num import RE_DEFAULT_NUM
|
||||||
from .num import RE_FRAC
|
from .num import RE_FRAC
|
||||||
@ -36,6 +37,7 @@ from .num import RE_RANGE
|
|||||||
from .num import RE_TO_RANGE
|
from .num import RE_TO_RANGE
|
||||||
from .num import RE_ASMD
|
from .num import RE_ASMD
|
||||||
from .num import RE_POWER
|
from .num import RE_POWER
|
||||||
|
from .num import replace_vrsion_num
|
||||||
from .num import replace_default_num
|
from .num import replace_default_num
|
||||||
from .num import replace_frac
|
from .num import replace_frac
|
||||||
from .num import replace_negative_num
|
from .num import replace_negative_num
|
||||||
@ -158,6 +160,7 @@ class TextNormalizer:
|
|||||||
sentence = RE_RANGE.sub(replace_range, sentence)
|
sentence = RE_RANGE.sub(replace_range, sentence)
|
||||||
|
|
||||||
sentence = RE_INTEGER.sub(replace_negative_num, sentence)
|
sentence = RE_INTEGER.sub(replace_negative_num, sentence)
|
||||||
|
sentence = RE_VERSION_NUM.sub(replace_vrsion_num, sentence)
|
||||||
sentence = RE_DECIMAL_NUM.sub(replace_number, sentence)
|
sentence = RE_DECIMAL_NUM.sub(replace_number, sentence)
|
||||||
sentence = RE_POSITIVE_QUANTIFIERS.sub(replace_positive_quantifier, sentence)
|
sentence = RE_POSITIVE_QUANTIFIERS.sub(replace_positive_quantifier, sentence)
|
||||||
sentence = RE_DEFAULT_NUM.sub(replace_default_num, sentence)
|
sentence = RE_DEFAULT_NUM.sub(replace_default_num, sentence)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user