From 06e1a7029aee85f53f49dece3712ad9c1bef1bef Mon Sep 17 00:00:00 2001 From: Mikei386 <44135113+Mikei386@users.noreply.github.com> Date: Sun, 23 Aug 2026 13:58:04 +0200 Subject: [PATCH] Normalize wind speed units for German TTS --- platform/docker/tts-gateway/test_tts_gateway.py | 11 +++++++++++ platform/docker/tts-gateway/tts_gateway.py | 6 ++++++ 2 files changed, 17 insertions(+) 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