enhuiz commited on
Commit
a3b14a2
1 Parent(s): aa1731e

Add an unlimited flag and instructions

Browse files
Files changed (1) hide show
  1. app.py +33 -7
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import gradio as gr
2
  import torch
3
  import torchaudio
@@ -10,13 +13,13 @@ else:
10
  device = "cpu"
11
 
12
 
13
- def _fn(path, solver, nfe, tau, denoising):
14
  if path is None:
15
  gr.Warning("Please upload an audio file.")
16
  return None, None
17
 
18
  info = torchaudio.info(path)
19
- if info.num_frames / info.sample_rate > 60:
20
  gr.Warning("Only audio files shorter than 60 seconds are supported.")
21
  return None, None
22
 
@@ -37,12 +40,35 @@ def _fn(path, solver, nfe, tau, denoising):
37
 
38
 
39
  def main():
 
 
 
 
40
  inputs: list = [
41
  gr.Audio(type="filepath", label="Input Audio"),
42
- gr.Dropdown(choices=["Midpoint", "RK4", "Euler"], value="Midpoint", label="CFM ODE Solver"),
43
- gr.Slider(minimum=1, maximum=128, value=64, step=1, label="CFM Number of Function Evaluations"),
44
- gr.Slider(minimum=0, maximum=1, value=0.5, step=0.01, label="CFM Prior Temperature"),
45
- gr.Checkbox(value=False, label="Denoise Before Enhancement"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ]
47
 
48
  outputs: list = [
@@ -51,7 +77,7 @@ def main():
51
  ]
52
 
53
  interface = gr.Interface(
54
- fn=_fn,
55
  title="Resemble Enhance",
56
  description="AI-driven audio enhancement for your audio files, powered by Resemble AI.",
57
  inputs=inputs,
 
1
+ import argparse
2
+ from functools import partial
3
+
4
  import gradio as gr
5
  import torch
6
  import torchaudio
 
13
  device = "cpu"
14
 
15
 
16
+ def _fn(path, solver, nfe, tau, denoising, unlimited):
17
  if path is None:
18
  gr.Warning("Please upload an audio file.")
19
  return None, None
20
 
21
  info = torchaudio.info(path)
22
+ if not unlimited and (info.num_frames / info.sample_rate > 60):
23
  gr.Warning("Only audio files shorter than 60 seconds are supported.")
24
  return None, None
25
 
 
40
 
41
 
42
  def main():
43
+ parser = argparse.ArgumentParser()
44
+ parser.add_argument("--unlimited", action="store_true")
45
+ args = parser.parse_args()
46
+
47
  inputs: list = [
48
  gr.Audio(type="filepath", label="Input Audio"),
49
+ gr.Dropdown(
50
+ choices=["Midpoint", "RK4", "Euler"],
51
+ value="Midpoint",
52
+ label="CFM ODE Solver (Midpoint is recommended)",
53
+ ),
54
+ gr.Slider(
55
+ minimum=1,
56
+ maximum=128,
57
+ value=64,
58
+ step=1,
59
+ label="CFM Number of Function Evaluations (higher values in general yield better quality but may be slower)",
60
+ ),
61
+ gr.Slider(
62
+ minimum=0,
63
+ maximum=1,
64
+ value=0.5,
65
+ step=0.01,
66
+ label="CFM Prior Temperature (higher values can improve quality but can reduce stability)",
67
+ ),
68
+ gr.Checkbox(
69
+ value=False,
70
+ label="Denoise Before Enhancement (tick if your audio contains heavy background noise)",
71
+ ),
72
  ]
73
 
74
  outputs: list = [
 
77
  ]
78
 
79
  interface = gr.Interface(
80
+ fn=partial(_fn, unlimited=args.unlimited),
81
  title="Resemble Enhance",
82
  description="AI-driven audio enhancement for your audio files, powered by Resemble AI.",
83
  inputs=inputs,