fix(xtts): use correct language code for Czech num2words call (#237)

* Fix num2words call using non-standard lang code

* build: update minimum num2words version

---------

Co-authored-by: Enno Hermann <enno.hermann@idiap.ch>
This commit is contained in:
Jan Zípek 2024-12-28 13:25:46 +01:00 committed by GitHub
parent f89ce41924
commit 98080e282c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -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": ", ",
@ -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"):

View File

@ -86,7 +86,7 @@ dependencies = [
# Bark
"encodec>=0.1.1",
# XTTS
"num2words>=0.5.11",
"num2words>=0.5.14",
"spacy[ja]>=3,<3.8",
]