Spaces:
Running
on
T4
Running
on
T4
Add an unlimited flag and instructions
Browse files
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(
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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,
|