Skip to content

Commit

Permalink
Fix num2words call using non-standard lang code
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaceKamen committed Dec 27, 2024
1 parent f89ce41 commit f6c2f9e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions TTS/tts/layers/xtts/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,12 @@ def _remove_dots(m):

def _expand_decimal_point(m, lang="en"):
amount = m.group(1).replace(",", ".")
return num2words(float(amount), lang=lang if lang != "cs" else "cz")
return num2words(float(amount), lang=lang)


def _expand_currency(m, lang="en", currency="USD"):
amount = float((re.sub(r"[^\d.]", "", m.group(0).replace(",", "."))))
full_amount = num2words(amount, to="currency", currency=currency, lang=lang if lang != "cs" else "cz")
full_amount = num2words(amount, to="currency", currency=currency, lang=lang)

and_equivalents = {
"en": ", ",
Expand Down Expand Up @@ -535,11 +535,11 @@ def _expand_currency(m, lang="en", currency="USD"):


def _expand_ordinal(m, lang="en"):
return num2words(int(m.group(1)), ordinal=True, lang=lang if lang != "cs" else "cz")
return num2words(int(m.group(1)), ordinal=True, lang=lang)


def _expand_number(m, lang="en"):
return num2words(int(m.group(0)), lang=lang if lang != "cs" else "cz")
return num2words(int(m.group(0)), lang=lang)


def expand_numbers_multilingual(text, lang="en"):
Expand Down

0 comments on commit f6c2f9e

Please sign in to comment.