Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -31,36 +31,24 @@ net_g = SynthesizerTrn(
|
|
31 |
_ = net_g.eval()
|
32 |
|
33 |
_ = utils.load_checkpoint("G_aatrox.pth", net_g, None)
|
34 |
-
import soundfile as sf
|
35 |
-
text = "\u6211\u662F\u4E9A\u6258\u514B\u65AF\uFF0C\u4E16\u754C\u7684\u7EC8\u7ED3\u8005\uFF01" #@param {type: 'string'}
|
36 |
-
length_scale = 1 #@param {type:"slider", min:0.1, max:3, step:0.05}
|
37 |
-
filename = 'test' #@param {type: "string"}
|
38 |
-
audio_path = f'/content/VITS-Aatrox/{filename}.wav'
|
39 |
-
stn_tst = get_text(text, hps)
|
40 |
-
with torch.no_grad():
|
41 |
-
x_tst = stn_tst.unsqueeze(0)
|
42 |
-
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
43 |
-
audio = net_g.infer(x_tst, x_tst_lengths, noise_scale=.667, noise_scale_w=0.8, length_scale=length_scale)[0][0,0].data.cpu().float().numpy()
|
44 |
-
ipd.display(ipd.Audio(audio, rate=hps.data.sampling_rate))
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
#
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
# app.launch()
|
|
|
31 |
_ = net_g.eval()
|
32 |
|
33 |
_ = utils.load_checkpoint("G_aatrox.pth", net_g, None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
def vc_fn(input):
|
36 |
+
stn_tst = get_text(input, hps)
|
37 |
+
with torch.no_grad():
|
38 |
+
x_tst = stn_tst.unsqueeze(0)
|
39 |
+
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
40 |
+
audio = net_g.infer(x_tst, x_tst_lengths, noise_scale=.667, noise_scale_w=0.8, length_scale=1)[0][0,0].data.cpu().float().numpy()
|
41 |
+
sampling_rate = 22050
|
42 |
+
return (sampling_rate,audio)
|
43 |
+
|
44 |
+
app = gr.Blocks()
|
45 |
+
with app:
|
46 |
+
with gr.Tabs():
|
47 |
+
with gr.TabItem("Basic"):
|
48 |
+
vc_input = gr.Textbox(label="Input Message")
|
49 |
+
vc_submit = gr.Button("Convert", variant="primary")
|
50 |
+
vc_output = gr.Audio(label="Output Audio")
|
51 |
+
#vc_output = ipd.display(ipd.Audio(vc_fn(get_text(vc_input, hps)), rate=hps.data.sampling_rate))
|
52 |
+
vc_submit.click(vc_fn, [vc_input], [vc_output])
|
53 |
+
|
54 |
+
app.launch()
|
|