Hendrik Schroeter commited on
Commit
00981f2
1 Parent(s): 2405b89

update to gradio 3.0

Browse files
Files changed (2) hide show
  1. app.py +5 -6
  2. requirements.txt +1 -1
app.py CHANGED
@@ -58,7 +58,7 @@ def mix_at_snr(clean, noise, snr, eps=1e-10):
58
  if noise.shape[1] < clean.shape[1]:
59
  noise = noise.repeat((1, int(math.ceil(clean.shape[1] / noise.shape[1]))))
60
  max_start = int(noise.shape[1] - clean.shape[1])
61
- start = torch.randint(0, max_start, ()).item()
62
  logger.debug(f"start: {start}, {clean.shape}")
63
  noise = noise[:, start : start + clean.shape[1]]
64
  E_speech = torch.mean(clean.pow(2)) + eps
@@ -118,7 +118,9 @@ def demo_fn(
118
  sample, meta = tmp
119
  sample = sample[..., : 10 * meta.sample_rate] # limit to 10 seconds
120
  if sample.dim() > 1 and sample.shape[0] > 1:
121
- assert sample.shape[1] > sample.shape[2], f"Expecting channels first, but got {sample.shape}"
 
 
122
  sample = sample.mean(dim=0, keepdim=True)
123
  logger.info(f"Loaded sample with shape {sample.shape}")
124
  if noise_fn is not None:
@@ -254,13 +256,11 @@ inputs = [
254
  label="Record your own voice",
255
  source="microphone",
256
  type="numpy",
257
- optional=True,
258
  ),
259
  gradio.inputs.Audio(
260
  label="Alternative: Upload audio sample",
261
  source="upload",
262
  type="filepath",
263
- optional=True,
264
  ),
265
  gradio.inputs.Dropdown(
266
  label="Add background noise",
@@ -286,8 +286,7 @@ iface = gradio.Interface(
286
  inputs=inputs,
287
  outputs=outputs,
288
  description=description,
289
- layout="horizontal",
290
  allow_flagging="never",
291
  article=markdown.markdown(open("usage.md").read()),
292
  )
293
- iface.launch(cache_examples=False, debug=True)
 
58
  if noise.shape[1] < clean.shape[1]:
59
  noise = noise.repeat((1, int(math.ceil(clean.shape[1] / noise.shape[1]))))
60
  max_start = int(noise.shape[1] - clean.shape[1])
61
+ start = torch.randint(0, max_start, ()).item() if max_start > 0 else 0
62
  logger.debug(f"start: {start}, {clean.shape}")
63
  noise = noise[:, start : start + clean.shape[1]]
64
  E_speech = torch.mean(clean.pow(2)) + eps
 
118
  sample, meta = tmp
119
  sample = sample[..., : 10 * meta.sample_rate] # limit to 10 seconds
120
  if sample.dim() > 1 and sample.shape[0] > 1:
121
+ assert (
122
+ sample.shape[1] > sample.shape[2]
123
+ ), f"Expecting channels first, but got {sample.shape}"
124
  sample = sample.mean(dim=0, keepdim=True)
125
  logger.info(f"Loaded sample with shape {sample.shape}")
126
  if noise_fn is not None:
 
256
  label="Record your own voice",
257
  source="microphone",
258
  type="numpy",
 
259
  ),
260
  gradio.inputs.Audio(
261
  label="Alternative: Upload audio sample",
262
  source="upload",
263
  type="filepath",
 
264
  ),
265
  gradio.inputs.Dropdown(
266
  label="Add background noise",
 
286
  inputs=inputs,
287
  outputs=outputs,
288
  description=description,
 
289
  allow_flagging="never",
290
  article=markdown.markdown(open("usage.md").read()),
291
  )
292
+ iface.launch(debug=True)
requirements.txt CHANGED
@@ -3,4 +3,4 @@ torchaudio
3
  deepfilternet==0.2.3
4
  matplotlib
5
  markdown
6
- gradio
 
3
  deepfilternet==0.2.3
4
  matplotlib
5
  markdown
6
+ gradio>=3.0