EDGAhab commited on
Commit
cf4721c
·
1 Parent(s): b171e56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -20
app.py CHANGED
@@ -31,24 +31,36 @@ net_g = SynthesizerTrn(
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 (audio, sampling_rate)
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()
 
 
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.cuda().unsqueeze(0)
42
+ x_tst_lengths = torch.LongTensor([stn_tst.size(0)]).cuda()
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
+ # def vc_fn(input):
48
+ # stn_tst = get_text(input, hps)
49
+ # with torch.no_grad():
50
+ # x_tst = stn_tst.unsqueeze(0)
51
+ # x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
52
+ # 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()
53
+ # sampling_rate = 22050
54
+ # return (audio, sampling_rate)
55
+ #
56
+ # app = gr.Blocks()
57
+ # with app:
58
+ # with gr.Tabs():
59
+ # with gr.TabItem("Basic"):
60
+ # vc_input = gr.Textbox(label="Input Message")
61
+ # vc_submit = gr.Button("Convert", variant="primary")
62
+ # vc_output = gr.Audio(label="Output Audio")
63
+ # #vc_output = ipd.display(ipd.Audio(vc_fn(get_text(vc_input, hps)), rate=hps.data.sampling_rate))
64
+ # vc_submit.click(vc_fn, [vc_input], [vc_output])
65
+
66
+ # app.launch()