Hendrik Schroeter commited on
Commit
7895c3a
1 Parent(s): bc174b1

Formatting and cleanup

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +22 -14
  3. requirements.txt +0 -1
.gitignore CHANGED
@@ -5,6 +5,7 @@
5
  out/
6
  export/
7
  DeepFilterNet/poetry.lock
 
8
 
9
  ### Rust gitignore ###
10
 
 
5
  out/
6
  export/
7
  DeepFilterNet/poetry.lock
8
+ gradio_cached_examples/
9
 
10
  ### Rust gitignore ###
11
 
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import math
2
  import tempfile
3
  from typing import Optional, Tuple, Union
 
4
  import gradio as gr
5
- import markdown
6
  import matplotlib.pyplot as plt
7
  import numpy as np
8
  import torch
@@ -98,7 +98,7 @@ def load_audio_gradio(
98
 
99
 
100
  def demo_fn(speech_upl: str, noise_type: str, snr: int, mic_input: str):
101
- if (mic_input):
102
  speech_upl = mic_input
103
  sr = config("sr", 48000, int, section="df")
104
  logger.info(f"Got parameters speech_upl: {speech_upl}, noise: {noise_type}, snr: {snr}")
@@ -256,14 +256,16 @@ def toggle(choice):
256
  with gr.Blocks() as demo:
257
  with gr.Row():
258
  gr.Markdown("## DeepFilterNet2 Demo")
259
- gr.Markdown("This demo denoises audio files using DeepFilterNet. Try it with your own voice!")
 
 
260
  with gr.Row():
261
  with gr.Column():
262
- radio = gr.Radio(["mic", "file"], value="file",
263
- label="How would you like to upload your audio?")
 
264
  mic_input = gr.Mic(label="Input", type="filepath", visible=False)
265
- audio_file = gr.Audio(
266
- type="filepath", label="Input", visible=True)
267
  inputs = [
268
  audio_file,
269
  gr.Dropdown(
@@ -276,7 +278,7 @@ with gr.Blocks() as demo:
276
  choices=["-5", "0", "10", "20"],
277
  value="10",
278
  ),
279
- mic_input
280
  ]
281
  btn = gr.Button("Generate")
282
  with gr.Column():
@@ -290,12 +292,18 @@ with gr.Blocks() as demo:
290
  ]
291
  btn.click(fn=demo_fn, inputs=inputs, outputs=outputs)
292
  radio.change(toggle, radio, [mic_input, audio_file])
293
- gr.Examples([
294
- ["./samples/p232_013_clean.wav", "Kitchen", "10"],
295
- ["./samples/p232_013_clean.wav", "Cafe", "10"],
296
- ["./samples/p232_019_clean.wav", "Cafe", "10"],
297
- ["./samples/p232_019_clean.wav", "River", "10"]],
298
- fn=demo_fn, inputs=inputs, outputs=outputs, cache_examples=True),
 
 
 
 
 
 
299
  gr.Markdown(open("usage.md").read())
300
 
301
 
 
1
  import math
2
  import tempfile
3
  from typing import Optional, Tuple, Union
4
+
5
  import gradio as gr
 
6
  import matplotlib.pyplot as plt
7
  import numpy as np
8
  import torch
 
98
 
99
 
100
  def demo_fn(speech_upl: str, noise_type: str, snr: int, mic_input: str):
101
+ if mic_input:
102
  speech_upl = mic_input
103
  sr = config("sr", 48000, int, section="df")
104
  logger.info(f"Got parameters speech_upl: {speech_upl}, noise: {noise_type}, snr: {snr}")
 
256
  with gr.Blocks() as demo:
257
  with gr.Row():
258
  gr.Markdown("## DeepFilterNet2 Demo")
259
+ gr.Markdown(
260
+ "This demo denoises audio files using DeepFilterNet. Try it with your own voice!"
261
+ )
262
  with gr.Row():
263
  with gr.Column():
264
+ radio = gr.Radio(
265
+ ["mic", "file"], value="file", label="How would you like to upload your audio?"
266
+ )
267
  mic_input = gr.Mic(label="Input", type="filepath", visible=False)
268
+ audio_file = gr.Audio(type="filepath", label="Input", visible=True)
 
269
  inputs = [
270
  audio_file,
271
  gr.Dropdown(
 
278
  choices=["-5", "0", "10", "20"],
279
  value="10",
280
  ),
281
+ mic_input,
282
  ]
283
  btn = gr.Button("Generate")
284
  with gr.Column():
 
292
  ]
293
  btn.click(fn=demo_fn, inputs=inputs, outputs=outputs)
294
  radio.change(toggle, radio, [mic_input, audio_file])
295
+ gr.Examples(
296
+ [
297
+ ["./samples/p232_013_clean.wav", "Kitchen", "10"],
298
+ ["./samples/p232_013_clean.wav", "Cafe", "10"],
299
+ ["./samples/p232_019_clean.wav", "Cafe", "10"],
300
+ ["./samples/p232_019_clean.wav", "River", "10"],
301
+ ],
302
+ fn=demo_fn,
303
+ inputs=inputs,
304
+ outputs=outputs,
305
+ cache_examples=True,
306
+ ),
307
  gr.Markdown(open("usage.md").read())
308
 
309
 
requirements.txt CHANGED
@@ -2,6 +2,5 @@ torch==1.13
2
  torchaudio==0.13
3
  deepfilternet==0.4.0
4
  matplotlib==3.6
5
- markdown==3.4
6
  gradio==3.17
7
  Pillow==9.3
 
2
  torchaudio==0.13
3
  deepfilternet==0.4.0
4
  matplotlib==3.6
 
5
  gradio==3.17
6
  Pillow==9.3