Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
import os
|
| 3 |
os.environ.setdefault("GRADIO_USE_CDN", "true")
|
| 4 |
|
| 5 |
-
# 'spaces'
|
| 6 |
try:
|
| 7 |
-
import spaces
|
| 8 |
except Exception:
|
| 9 |
class _DummySpaces:
|
| 10 |
def GPU(self, *_, **__):
|
|
@@ -178,13 +178,14 @@ def list_example_files(progress: Optional[gr.Progress] = None) -> List[str]:
|
|
| 178 |
|
| 179 |
def load_examples(_: Any = None, progress=gr.Progress()):
|
| 180 |
"""
|
| 181 |
-
Returns (
|
| 182 |
"""
|
| 183 |
paths = list_example_files(progress=progress)
|
| 184 |
if not paths:
|
| 185 |
-
return [], [], "No sample .wav files found in repo/samples/inputs."
|
| 186 |
-
|
| 187 |
-
|
|
|
|
| 188 |
|
| 189 |
def set_example_selection(idx_label: str, paths: List[str]) -> Tuple[str, str]:
|
| 190 |
"""When user picks an example, set the audio path + a suggested prompt."""
|
|
@@ -249,15 +250,17 @@ with gr.Blocks(title="SonicMaster β Text-Guided Restoration & Mastering", fill
|
|
| 249 |
gr.Markdown(
|
| 250 |
"## π§ SonicMaster\n"
|
| 251 |
"Upload audio or **load sample audios**, write a prompt, then click **Enhance**.\n"
|
| 252 |
-
"- First run downloads model weights & repo (progress will show).\n"
|
| 253 |
-
"- On failure, the **Status** box shows the exact error (we won't echo the input audio)."
|
| 254 |
)
|
| 255 |
with gr.Row():
|
| 256 |
with gr.Column(scale=1):
|
| 257 |
# Sample loader (lazy)
|
| 258 |
with gr.Accordion("Sample audios (10)", open=False):
|
| 259 |
load_btn = gr.Button("π₯ Load 10 sample audios")
|
| 260 |
-
samples_dropdown = gr.Dropdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
samples_state = gr.State([]) # holds absolute paths
|
| 262 |
|
| 263 |
in_audio = gr.Audio(label="Input Audio", type="filepath")
|
|
|
|
| 2 |
import os
|
| 3 |
os.environ.setdefault("GRADIO_USE_CDN", "true")
|
| 4 |
|
| 5 |
+
# Make 'spaces' safe locally too
|
| 6 |
try:
|
| 7 |
+
import spaces # HF Spaces SDK
|
| 8 |
except Exception:
|
| 9 |
class _DummySpaces:
|
| 10 |
def GPU(self, *_, **__):
|
|
|
|
| 178 |
|
| 179 |
def load_examples(_: Any = None, progress=gr.Progress()):
|
| 180 |
"""
|
| 181 |
+
Returns (dropdown_update, paths:list[str], status:str)
|
| 182 |
"""
|
| 183 |
paths = list_example_files(progress=progress)
|
| 184 |
if not paths:
|
| 185 |
+
return gr.Dropdown.update(choices=[], value=None), [], "No sample .wav files found in repo/samples/inputs."
|
| 186 |
+
labels = [f"{i+1:02d} β {Path(p).name}" for i, p in enumerate(paths)]
|
| 187 |
+
# Auto-select first item for convenience
|
| 188 |
+
return gr.Dropdown.update(choices=labels, value=labels[0]), paths, f"Loaded {len(paths)} sample audios."
|
| 189 |
|
| 190 |
def set_example_selection(idx_label: str, paths: List[str]) -> Tuple[str, str]:
|
| 191 |
"""When user picks an example, set the audio path + a suggested prompt."""
|
|
|
|
| 250 |
gr.Markdown(
|
| 251 |
"## π§ SonicMaster\n"
|
| 252 |
"Upload audio or **load sample audios**, write a prompt, then click **Enhance**.\n"
|
|
|
|
|
|
|
| 253 |
)
|
| 254 |
with gr.Row():
|
| 255 |
with gr.Column(scale=1):
|
| 256 |
# Sample loader (lazy)
|
| 257 |
with gr.Accordion("Sample audios (10)", open=False):
|
| 258 |
load_btn = gr.Button("π₯ Load 10 sample audios")
|
| 259 |
+
samples_dropdown = gr.Dropdown(
|
| 260 |
+
choices=[], value=None, # no default until choices are set
|
| 261 |
+
label="Pick a sample",
|
| 262 |
+
interactive=True,
|
| 263 |
+
)
|
| 264 |
samples_state = gr.State([]) # holds absolute paths
|
| 265 |
|
| 266 |
in_audio = gr.Audio(label="Input Audio", type="filepath")
|