添加分段合成
This commit is contained in:
26
webui.py
26
webui.py
@@ -24,6 +24,7 @@ from text import cleaned_text_to_sequence, get_bert
|
|||||||
from text.cleaner import clean_text
|
from text.cleaner import clean_text
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
net_g = None
|
net_g = None
|
||||||
|
|
||||||
@@ -103,22 +104,17 @@ def infer(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, sid, langua
|
|||||||
return audio
|
return audio
|
||||||
|
|
||||||
|
|
||||||
def tts_fn(
|
def tts_fn(text, speaker, sdp_ratio, noise_scale, noise_scale_w, length_scale):
|
||||||
text, speaker, sdp_ratio, noise_scale, noise_scale_w, length_scale, language
|
slices = text.split("|")
|
||||||
):
|
audio_list = []
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
audio = infer(
|
for slice in slices:
|
||||||
text,
|
audio = infer(slice, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker)
|
||||||
sdp_ratio=sdp_ratio,
|
audio_list.append(audio)
|
||||||
noise_scale=noise_scale,
|
silence = np.zeros(hps.data.sampling_rate) # 生成1秒的静音
|
||||||
noise_scale_w=noise_scale_w,
|
audio_list.append(silence) # 将静音添加到列表中
|
||||||
length_scale=length_scale,
|
audio_concat = np.concatenate(audio_list)
|
||||||
sid=speaker,
|
return "Success", (hps.data.sampling_rate, audio_concat)
|
||||||
language=language,
|
|
||||||
)
|
|
||||||
torch.cuda.empty_cache()
|
|
||||||
return "Success", (hps.data.sampling_rate, audio)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|||||||
Reference in New Issue
Block a user