diff --git a/platform/docker/tts-gateway/test_tts_gateway.py b/platform/docker/tts-gateway/test_tts_gateway.py index acce0c9..98f96e0 100644 --- a/platform/docker/tts-gateway/test_tts_gateway.py +++ b/platform/docker/tts-gateway/test_tts_gateway.py @@ -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): diff --git a/platform/docker/tts-gateway/tts_gateway.py b/platform/docker/tts-gateway/tts_gateway.py index 1e1f92a..90a01d8 100644 --- a/platform/docker/tts-gateway/tts_gateway.py +++ b/platform/docker/tts-gateway/tts_gateway.py @@ -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