From 2c1eb59283aba504c1d9ced7aa88ebdd218479d3 Mon Sep 17 00:00:00 2001 From: ling Date: Wed, 7 Feb 2024 19:41:41 +0800 Subject: [PATCH] feat: in case ignore too short text --- GPT_SoVITS/inference_webui.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/GPT_SoVITS/inference_webui.py b/GPT_SoVITS/inference_webui.py index c5e4ae6..3b4b2ba 100644 --- a/GPT_SoVITS/inference_webui.py +++ b/GPT_SoVITS/inference_webui.py @@ -342,6 +342,20 @@ def get_bert_final(phones, word2ph, text,language,device): bert = torch.zeros((1024, len(phones))).to(device) return bert +def merge_short_text_in_array(texts, threshold): + if (len(texts)) < 2: + return texts + result = [] + text = "" + for ele in texts: + text += ele + if len(text) >= threshold: + result.append(text) + text = "" + if (len(text) > 0): + result[len(result)] += text + return result + def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language, how_to_cut=i18n("不切")): t0 = ttime() prompt_language = dict_language[prompt_language] @@ -394,6 +408,7 @@ def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language, text = text.replace("\n\n", "\n") print(i18n("实际输入的目标文本(切句后):"), text) texts = text.split("\n") + texts = merge_short_text_in_array(texts, 5) audio_opt = [] bert1=get_bert_final(phones1, word2ph1, norm_text1,prompt_language,device).to(dtype)