brentspell commited on
Commit
012976e
1 Parent(s): 66dcbda

add audio processing

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
1
  import gradio
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gradio.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio
2
+ import numpy as np
3
+ import torch
4
+ from hifi_gan_bwe import BandwidthExtender
5
 
6
+ model = BandwidthExtender.from_pretrained("hifi-gan-bwe-05-d3abf04-vctk-48kHz")
 
7
 
8
+
9
+ def extend(audio):
10
+ fs, x = audio
11
+ x = x.astype(np.float32) / 32767.0
12
+
13
+ with torch.no_grad():
14
+ y = model(torch.from_numpy(x), fs).numpy()
15
+ fs = int(model.sample_rate)
16
+ y = (y * 32767.0).astype(np.int16)
17
+
18
+ return fs, y
19
+
20
+
21
+ gradio.Interface(
22
+ fn=extend,
23
+ inputs="audio",
24
+ outputs="audio",
25
+ ).launch()