Spaces:
Build error
Build error
brentspell
commited on
Commit
•
012976e
1
Parent(s):
66dcbda
add audio processing
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
1 |
import gradio
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|