From d8d65415d19727cd5f3a93d7ed4bd68e24431da3 Mon Sep 17 00:00:00 2001 From: RVC-Boss <129054828+RVC-Boss@users.noreply.github.com> Date: Sun, 28 Jan 2024 20:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=A4=B4=E5=90=9E?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GPT_SoVITS/inference_webui.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/GPT_SoVITS/inference_webui.py b/GPT_SoVITS/inference_webui.py index 454a372..d601d9f 100644 --- a/GPT_SoVITS/inference_webui.py +++ b/GPT_SoVITS/inference_webui.py @@ -29,10 +29,10 @@ else: # ) # sovits_path = os.environ.get("sovits_path", "pretrained_models/s2G488k.pth") cnhubert_base_path = os.environ.get( - "cnhubert_base_path", "pretrained_models/chinese-hubert-base" + "cnhubert_base_path", "GPT_SoVITS/pretrained_models/chinese-hubert-base" ) bert_path = os.environ.get( - "bert_path", "pretrained_models/chinese-roberta-wwm-ext-large" + "bert_path", "GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large" ) infer_ttswebui = os.environ.get("infer_ttswebui", 9872) infer_ttswebui = int(infer_ttswebui) @@ -262,11 +262,18 @@ def nonen_get_bert_inf(text, language): return bert +splits = {",","。","?","!",",",".","?","!","~",":",":","—","…",} +def get_first(text): + pattern = "[" + "".join(re.escape(sep) for sep in splits) + "]" + text = re.split(pattern, text)[0].strip() + return text + def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,how_to_cut=i18n("不切")): t0 = ttime() prompt_text = prompt_text.strip("\n") if(prompt_text[-1]not in splits):prompt_text+="。"if prompt_text!="en"else "." text = text.strip("\n") + if(len(get_first(text))<4):text+="。"if text!="en"else "." zero_wav = np.zeros( int(hps.data.sampling_rate * 0.3), dtype=np.float16 if is_half == True else np.float32, @@ -371,24 +378,6 @@ def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language, np.int16 ) - -splits = { - ",", - "。", - "?", - "!", - ",", - ".", - "?", - "!", - "~", - ":", - ":", - "—", - "…", -} # 不考虑省略号 - - def split(todo_text): todo_text = todo_text.replace("……", "。").replace("——", ",") if todo_text[-1] not in splits: