Skip to content

Commit

Permalink
fix: convert >35 digit English numbers digit-by-digit (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostways authored Jan 6, 2025
1 parent eaff93d commit 49fa9b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion TTS/tts/utils/text/english/number_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def _expand_number(m):
if num % 100 == 0:
return _inflect.number_to_words(num // 100) + " hundred"
return _inflect.number_to_words(num, andword="", zero="oh", group=2).replace(", ", " ")
return _inflect.number_to_words(num, andword="")
try:
text = _inflect.number_to_words(num, andword="")
except inflect.NumOutOfRangeError:
text = _inflect.number_to_words(num, group=1).replace(", ", " ")
return text


def normalize_numbers(text):
Expand Down
2 changes: 2 additions & 0 deletions tests/text_tests/test_text_cleaners.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def test_currency() -> None:
def test_expand_numbers() -> None:
assert phoneme_cleaners("-1") == "minus one"
assert phoneme_cleaners("1") == "one"
assert phoneme_cleaners("1" + "0" * 35) == "one hundred decillion"
assert phoneme_cleaners("1" + "0" * 36) == "one" + " zero" * 36


def test_multilingual_phoneme_cleaners() -> None:
Expand Down

0 comments on commit 49fa9b9

Please sign in to comment.