Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting large numbers to text causes crash #240

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

lostways
Copy link

Explanation of issue

When trying to convert numbers to words in coqui-ai-TTS/TTS/tts/utils/text/english/number_norm.py, numbers with more than 36 digits will cause inflect to throw inflect.NumOutOfRangeError crashing the app.

Reproduction

This script will reproduce the issue:

from TTS.api import TTS

tts = TTS("tts_models/en/ljspeech/tacotron2-DDC").to("cuda")

# big_number = "1" + "0" * 35 # this will work
big_number = "1" + "0" * 36  # this will not work
text = f"The number is {big_number}"
tts.tts_to_file(
    text=text,
    file_path="output.wav",
)

Solution

The solution is to read out numbers with more than 36 digits one digit at a time. This replicates how a human speaker might handle this. For example reading out digits of pi.

Tests

I have added two tests to verify this change. One will convert a number with 35 digits normally and the other will convert a number with 36 digits.

Copy link
Member

@eginhard eginhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR and adding a test as well! It's a bit of an extreme case, but the fix is simple enough.

@eginhard eginhard merged commit 49fa9b9 into idiap:dev Jan 6, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants