Spaces:
Running
Running
Hendrik Schroeter
commited on
Commit
•
74a3076
1
Parent(s):
b8708f4
Clear axis before plotting again
Browse files
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 💩
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
|
|
1 |
---
|
2 |
+
title: DeepFilterNet2
|
3 |
emoji: 💩
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
app.py
CHANGED
@@ -21,6 +21,10 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
21 |
model, df, _ = init_df("./DeepFilterNet2", config_allow_defaults=True)
|
22 |
model = model.to(device=device).eval()
|
23 |
|
|
|
|
|
|
|
|
|
24 |
fig_noisy, ax_noisy = plt.subplots(figsize=(15.2, 5))
|
25 |
fig_noisy.set_tight_layout(True)
|
26 |
fig_enh, ax_enh = plt.subplots(figsize=(15.2, 5))
|
@@ -124,15 +128,17 @@ def demo_fn(
|
|
124 |
lim = torch.linspace(0.0, 1.0, int(sr * 0.15)).unsqueeze(0)
|
125 |
lim = torch.cat((lim, torch.ones(1, enhanced.shape[1] - lim.shape[1])), dim=1)
|
126 |
enhanced = enhanced * lim
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
noisy_fn = tempfile.NamedTemporaryFile(suffix="noisy.wav", delete=False).name
|
132 |
save_audio(noisy_fn, sample, sr)
|
133 |
enhanced_fn = tempfile.NamedTemporaryFile(suffix="enhanced.wav", delete=False).name
|
134 |
save_audio(enhanced_fn, enhanced, sr)
|
135 |
logger.info(f"saved audios: {noisy_fn}, {enhanced_fn}")
|
|
|
|
|
136 |
return (
|
137 |
noisy_fn,
|
138 |
spec_figure(sample, sr=sr, figure=fig_noisy, ax=ax_noisy),
|
|
|
21 |
model, df, _ = init_df("./DeepFilterNet2", config_allow_defaults=True)
|
22 |
model = model.to(device=device).eval()
|
23 |
|
24 |
+
fig_noisy: plt.Figure
|
25 |
+
fig_enh: plt.Figure
|
26 |
+
ax_noisy: plt.Axes
|
27 |
+
ax_enh: plt.Axes
|
28 |
fig_noisy, ax_noisy = plt.subplots(figsize=(15.2, 5))
|
29 |
fig_noisy.set_tight_layout(True)
|
30 |
fig_enh, ax_enh = plt.subplots(figsize=(15.2, 5))
|
|
|
128 |
lim = torch.linspace(0.0, 1.0, int(sr * 0.15)).unsqueeze(0)
|
129 |
lim = torch.cat((lim, torch.ones(1, enhanced.shape[1] - lim.shape[1])), dim=1)
|
130 |
enhanced = enhanced * lim
|
131 |
+
if meta.sample_rate != sr:
|
132 |
+
enhanced = resample(enhanced, sr, meta.sample_rate)
|
133 |
+
sample = resample(sample, sr, meta.sample_rate)
|
134 |
+
sr = meta.sample_rate
|
135 |
noisy_fn = tempfile.NamedTemporaryFile(suffix="noisy.wav", delete=False).name
|
136 |
save_audio(noisy_fn, sample, sr)
|
137 |
enhanced_fn = tempfile.NamedTemporaryFile(suffix="enhanced.wav", delete=False).name
|
138 |
save_audio(enhanced_fn, enhanced, sr)
|
139 |
logger.info(f"saved audios: {noisy_fn}, {enhanced_fn}")
|
140 |
+
ax_noisy.clear()
|
141 |
+
ax_enh.clear()
|
142 |
return (
|
143 |
noisy_fn,
|
144 |
spec_figure(sample, sr=sr, figure=fig_noisy, ax=ax_noisy),
|