Skip to content

Commit 698e965

Browse files
authored
修复开头吞字
1 parent b8ae5a2 commit 698e965

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

GPT_SoVITS/inference_webui.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
# )
3030
# sovits_path = os.environ.get("sovits_path", "pretrained_models/s2G488k.pth")
3131
cnhubert_base_path = os.environ.get(
32-
"cnhubert_base_path", "pretrained_models/chinese-hubert-base"
32+
"cnhubert_base_path", "GPT_SoVITS/pretrained_models/chinese-hubert-base"
3333
)
3434
bert_path = os.environ.get(
35-
"bert_path", "pretrained_models/chinese-roberta-wwm-ext-large"
35+
"bert_path", "GPT_SoVITS/pretrained_models/chinese-roberta-wwm-ext-large"
3636
)
3737
infer_ttswebui = os.environ.get("infer_ttswebui", 9872)
3838
infer_ttswebui = int(infer_ttswebui)
@@ -262,11 +262,18 @@ def nonen_get_bert_inf(text, language):
262262

263263
return bert
264264

265+
splits = {",","。","?","!",",",".","?","!","~",":",":","—","…",}
266+
def get_first(text):
267+
pattern = "[" + "".join(re.escape(sep) for sep in splits) + "]"
268+
text = re.split(pattern, text)[0].strip()
269+
return text
270+
265271
def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,how_to_cut=i18n("不切")):
266272
t0 = ttime()
267273
prompt_text = prompt_text.strip("\n")
268274
if(prompt_text[-1]not in splits):prompt_text+="。"if prompt_text!="en"else "."
269275
text = text.strip("\n")
276+
if(len(get_first(text))<4):text+="。"if text!="en"else "."
270277
zero_wav = np.zeros(
271278
int(hps.data.sampling_rate * 0.3),
272279
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,
371378
np.int16
372379
)
373380

374-
375-
splits = {
376-
",",
377-
"。",
378-
"?",
379-
"!",
380-
",",
381-
".",
382-
"?",
383-
"!",
384-
"~",
385-
":",
386-
":",
387-
"—",
388-
"…",
389-
} # 不考虑省略号
390-
391-
392381
def split(todo_text):
393382
todo_text = todo_text.replace("……", "。").replace("——", ",")
394383
if todo_text[-1] not in splits:

0 commit comments

Comments
 (0)