Spaces:
Build error
Build error
Commit
·
a0c929e
1
Parent(s):
521e6a5
Upload app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
import re
|
3 |
import gradio as gr
|
4 |
import torch
|
@@ -92,7 +91,7 @@ def selection(speaker):
|
|
92 |
spk = 8
|
93 |
return spk
|
94 |
|
95 |
-
def infer(text,speaker_id):
|
96 |
text = clean_text(text)
|
97 |
speaker_id = int(selection(speaker_id))
|
98 |
dev = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
@@ -102,7 +101,7 @@ def infer(text,speaker_id):
|
|
102 |
x_tst = stn_tst.unsqueeze(0).to(dev)
|
103 |
x_tst_lengths = torch.LongTensor([stn_tst.size(0)]).to(dev)
|
104 |
sid = torch.LongTensor([speaker_id]).to(dev)
|
105 |
-
audio = net_g_ms.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=
|
106 |
0, 0].data.cpu().float().numpy()
|
107 |
return (hps_ms.data.sampling_rate, audio)
|
108 |
|
@@ -110,10 +109,16 @@ idols = ["南小鸟","园田海未","小泉花阳","星空凛","东条希","矢
|
|
110 |
app = gr.Blocks()
|
111 |
with app:
|
112 |
with gr.Tabs():
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
116 |
tts_submit = gr.Button("Generate", variant="primary")
|
|
|
117 |
tts_output2 = gr.Audio(label="Output")
|
118 |
-
|
|
|
119 |
app.launch()
|
|
|
|
|
1 |
import re
|
2 |
import gradio as gr
|
3 |
import torch
|
|
|
91 |
spk = 8
|
92 |
return spk
|
93 |
|
94 |
+
def infer(text,speaker_id, n_scale= 0.667,n_scale_w = 0.8, l_scale = 1 ):
|
95 |
text = clean_text(text)
|
96 |
speaker_id = int(selection(speaker_id))
|
97 |
dev = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
|
101 |
x_tst = stn_tst.unsqueeze(0).to(dev)
|
102 |
x_tst_lengths = torch.LongTensor([stn_tst.size(0)]).to(dev)
|
103 |
sid = torch.LongTensor([speaker_id]).to(dev)
|
104 |
+
audio = net_g_ms.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=n_scale, noise_scale_w=n_scale_w, length_scale=l_scale)[0][
|
105 |
0, 0].data.cpu().float().numpy()
|
106 |
return (hps_ms.data.sampling_rate, audio)
|
107 |
|
|
|
109 |
app = gr.Blocks()
|
110 |
with app:
|
111 |
with gr.Tabs():
|
112 |
+
|
113 |
+
with gr.TabItem("Basic"):
|
114 |
+
|
115 |
+
tts_input1 = gr.TextArea(label="请输入纯中文或纯日文", value="大家好")
|
116 |
+
para_input1 = gr.Slider(minimum= 0.01,maximum=1.0,label="更改噪声比例", value=0.667)
|
117 |
+
para_input2 = gr.Slider(minimum= 0.01,maximum=1.0,label="更改噪声偏差", value=0.8)
|
118 |
+
para_input3 = gr.Slider(minimum= 0.1,maximum=10,label="更改时间比例", value=1)
|
119 |
tts_submit = gr.Button("Generate", variant="primary")
|
120 |
+
speaker1 = gr.Dropdown(label="选择说话人",choices=idols, value="高坂穗乃果", interactive=True)
|
121 |
tts_output2 = gr.Audio(label="Output")
|
122 |
+
|
123 |
+
tts_submit.click(infer, [tts_input1,speaker1,para_input1,para_input2,para_input3], [tts_output2])
|
124 |
app.launch()
|