Optimize short sentence (#1430)

This commit is contained in:
KamioRinn
2024-08-10 12:28:53 +08:00
committed by GitHub
parent 893b45246b
commit 2310bcde53
3 changed files with 10 additions and 4 deletions

5
api.py
View File

@@ -275,7 +275,7 @@ def get_bert_inf(phones, word2ph, norm_text, language):
return bert
from text import chinese
def get_phones_and_bert(text,language,version):
def get_phones_and_bert(text,language,version,final=False):
if language in {"en", "all_zh", "all_ja", "all_ko", "all_yue"}:
language = language.replace("all_","")
if language == "en":
@@ -340,6 +340,9 @@ def get_phones_and_bert(text,language,version):
phones = sum(phones_list, [])
norm_text = ''.join(norm_text_list)
if not final and len(phones) < 6:
return get_phones_and_bert("." + text,language,version,final=True)
return phones,bert.to(torch.float16 if is_half == True else torch.float32),norm_text