修正多语言推理

This commit is contained in:
Stardust·减
2023-10-04 21:44:18 +08:00
committed by GitHub
parent 8e17a1fdd9
commit ae55007c5c

View File

@@ -101,15 +101,16 @@ def infer(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, sid, langua
.numpy() .numpy()
) )
del x_tst, tones, lang_ids, bert, x_tst_lengths, speakers del x_tst, tones, lang_ids, bert, x_tst_lengths, speakers
torch.cuda.empty_cache()
return audio return audio
def tts_fn(text, speaker, sdp_ratio, noise_scale, noise_scale_w, length_scale): def tts_fn(text, speaker, sdp_ratio, noise_scale, noise_scale_w, length_scale, language):
slices = text.split("|") slices = text.split("|")
audio_list = [] audio_list = []
with torch.no_grad(): with torch.no_grad():
for slice in slices: for slice in slices:
audio = infer(slice, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker) audio = infer(slice, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker, language=language)
audio_list.append(audio) audio_list.append(audio)
silence = np.zeros(hps.data.sampling_rate) # 生成1秒的静音 silence = np.zeros(hps.data.sampling_rate) # 生成1秒的静音
audio_list.append(silence) # 将静音添加到列表中 audio_list.append(silence) # 将静音添加到列表中