diff --git a/tests/test_normalizer.py b/tests/test_normalizer.py index 7f89da0ec..870df524e 100644 --- a/tests/test_normalizer.py +++ b/tests/test_normalizer.py @@ -46,6 +46,10 @@ def test_number_normalizer(std): assert std("fourteen point 4") == "14.4" assert std("one point five") == "1.5" assert std("two point two five dollars") == "$2.25" + assert std("that was the point and then") == "that was the point and then" + assert std("match point minus two") == "match point -2" + assert std("good point first of all") == "good point 1st of all" + assert std("two point and") == "2 point and" assert std("two hundred million dollars") == "$200000000" assert std("$20.1 million") == "$20100000" diff --git a/whisper/normalizers/english.py b/whisper/normalizers/english.py index 21c3a54e5..ba94be63d 100644 --- a/whisper/normalizers/english.py +++ b/whisper/normalizers/english.py @@ -375,6 +375,11 @@ def output(result: Union[str, int]): elif current == "point": if next in self.decimals or next_is_numeric: value = str(value or "") + "." + else: + # not a decimal point, e.g. "the point and", "match point minus" + if value is not None: + yield output(value) + yield output(current) else: # should all have been covered at this point raise ValueError(f"Unexpected token: {current}")