mirror of https://github.com/coqui-ai/TTS.git
Fix zh bug (#3238)
This commit is contained in:
parent
675f983550
commit
fbc18b8c34
|
@ -170,7 +170,7 @@ _abbreviations = {
|
||||||
# There are not many common abbreviations in Arabic as in English.
|
# There are not many common abbreviations in Arabic as in English.
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"zh-cn": [
|
"zh": [
|
||||||
(re.compile("\\b%s\\." % x[0], re.IGNORECASE), x[1])
|
(re.compile("\\b%s\\." % x[0], re.IGNORECASE), x[1])
|
||||||
for x in [
|
for x in [
|
||||||
# Chinese doesn't typically use abbreviations in the same way as Latin-based scripts.
|
# Chinese doesn't typically use abbreviations in the same way as Latin-based scripts.
|
||||||
|
@ -335,7 +335,7 @@ _symbols_multilingual = {
|
||||||
("°", " درجة "),
|
("°", " درجة "),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"zh-cn": [
|
"zh": [
|
||||||
# Chinese
|
# Chinese
|
||||||
(re.compile(r"%s" % re.escape(x[0]), re.IGNORECASE), x[1])
|
(re.compile(r"%s" % re.escape(x[0]), re.IGNORECASE), x[1])
|
||||||
for x in [
|
for x in [
|
||||||
|
@ -619,6 +619,7 @@ class VoiceBpeTokenizer:
|
||||||
return cutlet.Cutlet()
|
return cutlet.Cutlet()
|
||||||
|
|
||||||
def check_input_length(self, txt, lang):
|
def check_input_length(self, txt, lang):
|
||||||
|
lang = lang.split("-")[0] # remove the region
|
||||||
limit = self.char_limits.get(lang, 250)
|
limit = self.char_limits.get(lang, 250)
|
||||||
if len(txt) > limit:
|
if len(txt) > limit:
|
||||||
print(
|
print(
|
||||||
|
@ -626,7 +627,7 @@ class VoiceBpeTokenizer:
|
||||||
)
|
)
|
||||||
|
|
||||||
def preprocess_text(self, txt, lang):
|
def preprocess_text(self, txt, lang):
|
||||||
if lang in {"ar", "cs", "de", "en", "es", "fr", "hu", "it", "nl", "pl", "pt", "ru", "tr", "zh-cn", "ko"}:
|
if lang in {"ar", "cs", "de", "en", "es", "fr", "hu", "it", "nl", "pl", "pt", "ru", "tr", "zh", "ko"}:
|
||||||
txt = multilingual_cleaners(txt, lang)
|
txt = multilingual_cleaners(txt, lang)
|
||||||
if lang == "zh":
|
if lang == "zh":
|
||||||
txt = chinese_transliterate(txt)
|
txt = chinese_transliterate(txt)
|
||||||
|
@ -642,6 +643,7 @@ class VoiceBpeTokenizer:
|
||||||
lang = lang.split("-")[0] # remove the region
|
lang = lang.split("-")[0] # remove the region
|
||||||
self.check_input_length(txt, lang)
|
self.check_input_length(txt, lang)
|
||||||
txt = self.preprocess_text(txt, lang)
|
txt = self.preprocess_text(txt, lang)
|
||||||
|
lang = "zh-cn" if lang == "zh" else lang
|
||||||
txt = f"[{lang}]{txt}"
|
txt = f"[{lang}]{txt}"
|
||||||
txt = txt.replace(" ", "[SPACE]")
|
txt = txt.replace(" ", "[SPACE]")
|
||||||
return self.tokenizer.encode(txt).ids
|
return self.tokenizer.encode(txt).ids
|
||||||
|
@ -738,8 +740,8 @@ def test_expand_numbers_multilingual():
|
||||||
("Dat wordt dan $20 meneer.", "Dat wordt dan twintig dollar meneer.", "nl"),
|
("Dat wordt dan $20 meneer.", "Dat wordt dan twintig dollar meneer.", "nl"),
|
||||||
("Dat wordt dan 20€ meneer.", "Dat wordt dan twintig euro meneer.", "nl"),
|
("Dat wordt dan 20€ meneer.", "Dat wordt dan twintig euro meneer.", "nl"),
|
||||||
# Chinese (Simplified)
|
# Chinese (Simplified)
|
||||||
("在12.5秒内", "在十二点五秒内", "zh-cn"),
|
("在12.5秒内", "在十二点五秒内", "zh"),
|
||||||
("有50名士兵", "有五十名士兵", "zh-cn"),
|
("有50名士兵", "有五十名士兵", "zh"),
|
||||||
# ("那将是$20先生", '那将是二十美元先生', 'zh'), currency doesn't work
|
# ("那将是$20先生", '那将是二十美元先生', 'zh'), currency doesn't work
|
||||||
# ("那将是20€先生", '那将是二十欧元先生', 'zh'),
|
# ("那将是20€先生", '那将是二十欧元先生', 'zh'),
|
||||||
# Turkish
|
# Turkish
|
||||||
|
@ -820,7 +822,7 @@ def test_symbols_multilingual():
|
||||||
("Ik heb 14% batterij", "Ik heb 14 procent batterij", "nl"),
|
("Ik heb 14% batterij", "Ik heb 14 procent batterij", "nl"),
|
||||||
("Ik zie je @ het feest", "Ik zie je bij het feest", "nl"),
|
("Ik zie je @ het feest", "Ik zie je bij het feest", "nl"),
|
||||||
("لدي 14% في البطارية", "لدي 14 في المئة في البطارية", "ar"),
|
("لدي 14% في البطارية", "لدي 14 في المئة في البطارية", "ar"),
|
||||||
("我的电量为 14%", "我的电量为 14 百分之", "zh-cn"),
|
("我的电量为 14%", "我的电量为 14 百分之", "zh"),
|
||||||
("Pilim %14 dolu.", "Pilim yüzde 14 dolu.", "tr"),
|
("Pilim %14 dolu.", "Pilim yüzde 14 dolu.", "tr"),
|
||||||
("Az akkumulátorom töltöttsége 14%", "Az akkumulátorom töltöttsége 14 százalék", "hu"),
|
("Az akkumulátorom töltöttsége 14%", "Az akkumulátorom töltöttsége 14 százalék", "hu"),
|
||||||
("배터리 잔량이 14%입니다.", "배터리 잔량이 14 퍼센트입니다.", "ko"),
|
("배터리 잔량이 14%입니다.", "배터리 잔량이 14 퍼센트입니다.", "ko"),
|
||||||
|
|
|
@ -396,7 +396,7 @@ class Xtts(BaseTTS):
|
||||||
inference with config
|
inference with config
|
||||||
"""
|
"""
|
||||||
assert (
|
assert (
|
||||||
language in self.config.languages
|
"zh-cn" if language == "zh" else language in self.config.languages
|
||||||
), f" ❗ Language {language} is not supported. Supported languages are {self.config.languages}"
|
), f" ❗ Language {language} is not supported. Supported languages are {self.config.languages}"
|
||||||
# Use generally found best tuning knobs for generation.
|
# Use generally found best tuning knobs for generation.
|
||||||
settings = {
|
settings = {
|
||||||
|
|
Loading…
Reference in New Issue