|
29 | 29 | # ) |
30 | 30 | # sovits_path = os.environ.get("sovits_path", "pretrained_models/s2G488k.pth") |
31 | 31 | 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" |
33 | 33 | ) |
34 | 34 | 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" |
36 | 36 | ) |
37 | 37 | infer_ttswebui = os.environ.get("infer_ttswebui", 9872) |
38 | 38 | infer_ttswebui = int(infer_ttswebui) |
@@ -262,11 +262,18 @@ def nonen_get_bert_inf(text, language): |
262 | 262 |
|
263 | 263 | return bert |
264 | 264 |
|
| 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 | + |
265 | 271 | def get_tts_wav(ref_wav_path, prompt_text, prompt_language, text, text_language,how_to_cut=i18n("不切")): |
266 | 272 | t0 = ttime() |
267 | 273 | prompt_text = prompt_text.strip("\n") |
268 | 274 | if(prompt_text[-1]not in splits):prompt_text+="。"if prompt_text!="en"else "." |
269 | 275 | text = text.strip("\n") |
| 276 | + if(len(get_first(text))<4):text+="。"if text!="en"else "." |
270 | 277 | zero_wav = np.zeros( |
271 | 278 | int(hps.data.sampling_rate * 0.3), |
272 | 279 | 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, |
371 | 378 | np.int16 |
372 | 379 | ) |
373 | 380 |
|
374 | | - |
375 | | -splits = { |
376 | | - ",", |
377 | | - "。", |
378 | | - "?", |
379 | | - "!", |
380 | | - ",", |
381 | | - ".", |
382 | | - "?", |
383 | | - "!", |
384 | | - "~", |
385 | | - ":", |
386 | | - ":", |
387 | | - "—", |
388 | | - "…", |
389 | | -} # 不考虑省略号 |
390 | | - |
391 | | - |
392 | 381 | def split(todo_text): |
393 | 382 | todo_text = todo_text.replace("……", "。").replace("——", ",") |
394 | 383 | if todo_text[-1] not in splits: |
|
0 commit comments