Skip to content

Commit

Permalink
fixed large number conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
lostways committed Dec 30, 2024
1 parent 98080e2 commit 4b14774
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 4b14774

Please sign in to comment.