Normalize wind speed units for German TTS
This commit is contained in:
@@ -99,6 +99,17 @@ class LanguageSegmentationTests(unittest.TestCase):
|
||||
self.assertIn("example Punkt O R G", spoken)
|
||||
self.assertNotIn("https", spoken)
|
||||
|
||||
def test_wind_speed_is_spoken_as_a_unit(self):
|
||||
for text in (
|
||||
"Böen bis etwa 29 km/h.",
|
||||
"Böen bis etwa 29 KM / H.",
|
||||
"Wind mit 29 kmh.",
|
||||
):
|
||||
with self.subTest(text=text):
|
||||
spoken = gateway.clean_for_speech(text)
|
||||
self.assertIn("29 Kilometer pro Stunde", spoken)
|
||||
self.assertNotIn("km", spoken.lower())
|
||||
|
||||
|
||||
class FallbackTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
@@ -268,6 +268,12 @@ def normalize_for_german_speech(text: str) -> str:
|
||||
text,
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
text = re.sub(
|
||||
r"(-?\d+(?:[,.]\d+)?)\s*km\s*(?:/\s*)?h\b",
|
||||
r"\1 Kilometer pro Stunde",
|
||||
text,
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
text = re.sub(r"(\d)\s*%", r"\1 Prozent", text)
|
||||
return text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user