Spaces:
Sleeping
Sleeping
add app.py
Browse files- app.py +4 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import torch
|
3 |
import torchaudio
|
4 |
from denoisers import WaveUNetModel
|
|
|
5 |
|
6 |
MODEL = WaveUNetModel.from_pretrained("wrice/waveunet-vctk-24khz")
|
7 |
|
@@ -23,7 +25,7 @@ def denoise(inputs):
|
|
23 |
padded = torch.nn.functional.pad(audio, (0, padding))
|
24 |
|
25 |
clean = []
|
26 |
-
for i in range(0, padded.shape[-1], chunk_size):
|
27 |
audio_chunk = padded[:, i : i + chunk_size]
|
28 |
with torch.no_grad():
|
29 |
clean_chunk = MODEL(audio_chunk[None]).logits
|
@@ -34,7 +36,7 @@ def denoise(inputs):
|
|
34 |
|
35 |
print(f"Denoised shape: {denoised.shape}")
|
36 |
|
37 |
-
return MODEL.config.sample_rate, denoised
|
38 |
|
39 |
|
40 |
iface = gr.Interface(fn=denoise, inputs="audio", outputs="audio")
|
|
|
1 |
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
import torch
|
4 |
import torchaudio
|
5 |
from denoisers import WaveUNetModel
|
6 |
+
from tqdm import tqdm
|
7 |
|
8 |
MODEL = WaveUNetModel.from_pretrained("wrice/waveunet-vctk-24khz")
|
9 |
|
|
|
25 |
padded = torch.nn.functional.pad(audio, (0, padding))
|
26 |
|
27 |
clean = []
|
28 |
+
for i in tqdm(range(0, padded.shape[-1], chunk_size)):
|
29 |
audio_chunk = padded[:, i : i + chunk_size]
|
30 |
with torch.no_grad():
|
31 |
clean_chunk = MODEL(audio_chunk[None]).logits
|
|
|
36 |
|
37 |
print(f"Denoised shape: {denoised.shape}")
|
38 |
|
39 |
+
return MODEL.config.sample_rate, denoised[np.newaxis, :]
|
40 |
|
41 |
|
42 |
iface = gr.Interface(fn=denoise, inputs="audio", outputs="audio")
|
requirements.txt
CHANGED
@@ -7,3 +7,4 @@ denoisers
|
|
7 |
transformers
|
8 |
librosa
|
9 |
wandb
|
|
|
|
7 |
transformers
|
8 |
librosa
|
9 |
wandb
|
10 |
+
tqdm
|