mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2026-11-26 17:13:38 +08:00
Fix the end time of a time range being read as half past
replace_time checked the start time's minutes when deciding whether to read the end time as "半", so "8:30-12:15" became "八点半至十二点半" (the end time is spoken as 12:30) and "9:00-9:30" became "九点至九点三十分". Check minute_2 for the end time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
04a44eb977
commit
8b308e2913
@ -78,7 +78,7 @@ def replace_time(match) -> str:
|
||||
result += "至"
|
||||
result += f"{num2str(hour_2)}点"
|
||||
if minute_2.lstrip("0"):
|
||||
if int(minute) == 30:
|
||||
if int(minute_2) == 30:
|
||||
result += "半"
|
||||
else:
|
||||
result += f"{_time_num2str(minute_2)}分"
|
||||
|
||||
25
test_zh_normalization.py
Normal file
25
test_zh_normalization.py
Normal file
@ -0,0 +1,25 @@
|
||||
"""Regressions for 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.chronology import RE_TIME_RANGE, replace_time # noqa: E402
|
||||
|
||||
|
||||
def verbalize_time_range(text):
|
||||
return RE_TIME_RANGE.sub(replace_time, text)
|
||||
|
||||
|
||||
class TimeRangeTests(unittest.TestCase):
|
||||
def test_end_time_minutes_are_read_from_end_time(self):
|
||||
self.assertEqual(verbalize_time_range("8:30-12:15"), "八点半至十二点十五分")
|
||||
self.assertEqual(verbalize_time_range("9:00-9:30"), "九点至九点半")
|
||||
|
||||
def test_half_hour_on_both_ends(self):
|
||||
self.assertEqual(verbalize_time_range("8:30~9:30"), "八点半至九点半")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
x
Reference in New Issue
Block a user