Skip to content

Commit

Permalink
fix(xtts): use correct language code for Czech num2words call (#237)
Browse files Browse the repository at this point in the history
* Fix num2words call using non-standard lang code

* build: update minimum num2words version

---------

Co-authored-by: Enno Hermann <enno.hermann@idiap.ch>
  • Loading branch information
SkaceKamen and eginhard authored Dec 28, 2024
1 parent f89ce41 commit 98080e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ dependencies = [
# Bark
"encodec>=0.1.1",
# XTTS
"num2words>=0.5.11",
"num2words>=0.5.14",
"spacy[ja]>=3,<3.8",
]

Expand Down

0 comments on commit 98080e2

Please sign in to comment.