Normalize wind speed units for German TTS
This commit is contained in:
1 parent
c60031c957
commit
06e1a7029a
2 files changed
+17
No files matched your search
@@ -99,6 +99,17 @@ class LanguageSegmentationTests(unittest.TestCase):
|
|||||||
self.assertIn("example Punkt O R G", spoken)
|
self.assertIn("example Punkt O R G", spoken)
|
||||||
self.assertNotIn("https", 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):
|
class FallbackTests(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@@ -268,6 +268,12 @@ def normalize_for_german_speech(text: str) -> str:
|
|||||||
text,
|
text,
|
||||||
flags=re.IGNORECASE,
|
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)
|
text = re.sub(r"(\d)\s*%", r"\1 Prozent", text)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user