Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ with open(CONFIG) as f:
|
|
36 |
global trainset_config
|
37 |
trainset_config = config["trainset_config"] # to read trainset configurations
|
38 |
|
39 |
-
def denoise(filename, ckpt_path = CHECKPOINT):
|
40 |
"""
|
41 |
Denoise audio
|
42 |
Parameters:
|
@@ -66,7 +66,6 @@ def denoise(filename, ckpt_path = CHECKPOINT):
|
|
66 |
|
67 |
# inference
|
68 |
batch_size = 1000000
|
69 |
-
new_file_name = "denoised_" + filename
|
70 |
noisy_audio = load_simple(filename)
|
71 |
LENGTH = len(noisy_audio[0].squeeze())
|
72 |
noisy_audio = torch.chunk(noisy_audio, LENGTH // batch_size + 1, dim=1)
|
@@ -79,10 +78,9 @@ def denoise(filename, ckpt_path = CHECKPOINT):
|
|
79 |
all_audio.append(generated_audio)
|
80 |
|
81 |
all_audio = np.concatenate(all_audio, axis=0)
|
82 |
-
|
83 |
-
sf.write(new_file_name, np.ravel(all_audio.squeeze()), 32000)
|
84 |
|
85 |
-
return
|
86 |
|
87 |
|
88 |
audio = gr.inputs.Audio(label = "Audio to denoise", type = 'filepath')
|
|
|
36 |
global trainset_config
|
37 |
trainset_config = config["trainset_config"] # to read trainset configurations
|
38 |
|
39 |
+
def denoise(filename, ckpt_path = CHECKPOINT, out = "out.wav"):
|
40 |
"""
|
41 |
Denoise audio
|
42 |
Parameters:
|
|
|
66 |
|
67 |
# inference
|
68 |
batch_size = 1000000
|
|
|
69 |
noisy_audio = load_simple(filename)
|
70 |
LENGTH = len(noisy_audio[0].squeeze())
|
71 |
noisy_audio = torch.chunk(noisy_audio, LENGTH // batch_size + 1, dim=1)
|
|
|
78 |
all_audio.append(generated_audio)
|
79 |
|
80 |
all_audio = np.concatenate(all_audio, axis=0)
|
81 |
+
sf.write(out, np.ravel(all_audio.squeeze()), 32000)
|
|
|
82 |
|
83 |
+
return out
|
84 |
|
85 |
|
86 |
audio = gr.inputs.Audio(label = "Audio to denoise", type = 'filepath')
|