Commit
•
06bbc1f
1
Parent(s):
b0e88f3
Update app.py
Browse files
app.py
CHANGED
@@ -134,7 +134,7 @@ def demo_fn(speech_upl: str, noise_type: str, snr: int, mic_input: str):
|
|
134 |
snr = int(snr)
|
135 |
noise_fn = NOISES[noise_type]
|
136 |
meta = AudioMetaData(-1, -1, -1, -1, "")
|
137 |
-
max_s =
|
138 |
if speech_upl is not None:
|
139 |
sample, meta = load_audio(speech_upl, sr)
|
140 |
max_len = max_s * sr
|
@@ -164,8 +164,6 @@ def demo_fn(speech_upl: str, noise_type: str, snr: int, mic_input: str):
|
|
164 |
enhanced = resample(enhanced, sr, meta.sample_rate)
|
165 |
sample = resample(sample, sr, meta.sample_rate)
|
166 |
sr = meta.sample_rate
|
167 |
-
noisy_wav = tempfile.NamedTemporaryFile(suffix="noisy.wav", delete=False).name
|
168 |
-
save_audio(noisy_wav, sample, sr)
|
169 |
enhanced_wav = tempfile.NamedTemporaryFile(suffix="enhanced.wav", delete=False).name
|
170 |
save_audio(enhanced_wav, enhanced, sr)
|
171 |
logger.info(f"saved audios: {noisy_wav}, {enhanced_wav}")
|
@@ -173,7 +171,7 @@ def demo_fn(speech_upl: str, noise_type: str, snr: int, mic_input: str):
|
|
173 |
ax_enh.clear()
|
174 |
# noisy_wav = gr.make_waveform(noisy_fn, bar_count=200)
|
175 |
# enh_wav = gr.make_waveform(enhanced_fn, bar_count=200)
|
176 |
-
return
|
177 |
|
178 |
|
179 |
def specshow(
|
@@ -625,10 +623,9 @@ while run_server:
|
|
625 |
),
|
626 |
mic_input,
|
627 |
]
|
628 |
-
btn_denoise = gr.Button("Denoise")
|
629 |
with gr.Column():
|
630 |
outputs = [
|
631 |
-
gr.Audio(type="filepath", label="Noisy audio"),
|
632 |
gr.Audio(type="filepath", label="Enhanced audio"),
|
633 |
]
|
634 |
btn_denoise.click(fn=demo_fn, inputs=inputs, outputs=outputs)
|
|
|
134 |
snr = int(snr)
|
135 |
noise_fn = NOISES[noise_type]
|
136 |
meta = AudioMetaData(-1, -1, -1, -1, "")
|
137 |
+
max_s = 1000 # limit to 10 seconds
|
138 |
if speech_upl is not None:
|
139 |
sample, meta = load_audio(speech_upl, sr)
|
140 |
max_len = max_s * sr
|
|
|
164 |
enhanced = resample(enhanced, sr, meta.sample_rate)
|
165 |
sample = resample(sample, sr, meta.sample_rate)
|
166 |
sr = meta.sample_rate
|
|
|
|
|
167 |
enhanced_wav = tempfile.NamedTemporaryFile(suffix="enhanced.wav", delete=False).name
|
168 |
save_audio(enhanced_wav, enhanced, sr)
|
169 |
logger.info(f"saved audios: {noisy_wav}, {enhanced_wav}")
|
|
|
171 |
ax_enh.clear()
|
172 |
# noisy_wav = gr.make_waveform(noisy_fn, bar_count=200)
|
173 |
# enh_wav = gr.make_waveform(enhanced_fn, bar_count=200)
|
174 |
+
return enhanced_wav
|
175 |
|
176 |
|
177 |
def specshow(
|
|
|
623 |
),
|
624 |
mic_input,
|
625 |
]
|
626 |
+
btn_denoise = gr.Button("Denoise", variant="primary")
|
627 |
with gr.Column():
|
628 |
outputs = [
|
|
|
629 |
gr.Audio(type="filepath", label="Enhanced audio"),
|
630 |
]
|
631 |
btn_denoise.click(fn=demo_fn, inputs=inputs, outputs=outputs)
|