Spaces:
Running on Zero
Running on Zero
feat(app): wire generate tab end-to-end to ace-step backend
Browse files
app.py
CHANGED
|
@@ -43,10 +43,52 @@ os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
|
|
| 43 |
# Don't pin HF download source — let HF default for both Spaces and local cache.
|
| 44 |
os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
|
| 45 |
|
|
|
|
|
|
|
| 46 |
import gradio as gr
|
| 47 |
|
| 48 |
import ace_pipeline
|
|
|
|
|
|
|
| 49 |
import theme
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
HEADER_HTML = """
|
| 52 |
<div class="ams-header">
|
|
@@ -129,7 +171,12 @@ def build_app() -> gr.Blocks:
|
|
| 129 |
# --- Content ----------------------------------------------------
|
| 130 |
with gr.Column(scale=10, elem_classes=["ams-content"]):
|
| 131 |
with gr.Group(visible=True, elem_classes=["ams-tab-pane"]) as pane_generate:
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
with gr.Group(visible=False, elem_classes=["ams-tab-pane"]) as pane_cover:
|
| 134 |
gr.Markdown("### 🎤 Cover\n\nPlaceholder — implemented in M3.")
|
| 135 |
with gr.Group(visible=False, elem_classes=["ams-tab-pane"]) as pane_extend:
|
|
|
|
| 43 |
# Don't pin HF download source — let HF default for both Spaces and local cache.
|
| 44 |
os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
|
| 45 |
|
| 46 |
+
import random
|
| 47 |
+
|
| 48 |
import gradio as gr
|
| 49 |
|
| 50 |
import ace_pipeline
|
| 51 |
+
import backend as be
|
| 52 |
+
import modes
|
| 53 |
import theme
|
| 54 |
+
import ui
|
| 55 |
+
|
| 56 |
+
_BACKEND: be.ACEStepStudioBackend | None = None
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def get_backend() -> be.ACEStepStudioBackend:
|
| 60 |
+
global _BACKEND
|
| 61 |
+
if _BACKEND is None:
|
| 62 |
+
_BACKEND = be.ACEStepStudioBackend()
|
| 63 |
+
return _BACKEND
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def on_generate_click(
|
| 67 |
+
prompt: str,
|
| 68 |
+
lyrics: str,
|
| 69 |
+
duration_s: float,
|
| 70 |
+
instrumental_label: str,
|
| 71 |
+
progress=gr.Progress(track_tqdm=True), # noqa: B008
|
| 72 |
+
):
|
| 73 |
+
try:
|
| 74 |
+
out_path, meta = modes.generate(
|
| 75 |
+
get_backend(),
|
| 76 |
+
params={
|
| 77 |
+
"prompt": prompt,
|
| 78 |
+
"lyrics": lyrics,
|
| 79 |
+
"duration_s": int(duration_s),
|
| 80 |
+
"instrumental": instrumental_label == "Instrumental",
|
| 81 |
+
"seed": random.randint(1, 2_147_483_647),
|
| 82 |
+
"loras": [],
|
| 83 |
+
"advanced": {},
|
| 84 |
+
"lm": {},
|
| 85 |
+
"dcw": {},
|
| 86 |
+
},
|
| 87 |
+
)
|
| 88 |
+
except ValueError as e:
|
| 89 |
+
raise gr.Error(str(e)) from e
|
| 90 |
+
return out_path, meta
|
| 91 |
+
|
| 92 |
|
| 93 |
HEADER_HTML = """
|
| 94 |
<div class="ams-header">
|
|
|
|
| 171 |
# --- Content ----------------------------------------------------
|
| 172 |
with gr.Column(scale=10, elem_classes=["ams-content"]):
|
| 173 |
with gr.Group(visible=True, elem_classes=["ams-tab-pane"]) as pane_generate:
|
| 174 |
+
g = ui.build_generate_tab()
|
| 175 |
+
g["generate_btn"].click(
|
| 176 |
+
fn=on_generate_click,
|
| 177 |
+
inputs=[g["prompt"], g["lyrics"], g["duration_s"], g["instrumental"]],
|
| 178 |
+
outputs=[g["output_audio"], g["output_meta"]],
|
| 179 |
+
)
|
| 180 |
with gr.Group(visible=False, elem_classes=["ams-tab-pane"]) as pane_cover:
|
| 181 |
gr.Markdown("### 🎤 Cover\n\nPlaceholder — implemented in M3.")
|
| 182 |
with gr.Group(visible=False, elem_classes=["ams-tab-pane"]) as pane_extend:
|
ui.py
CHANGED
|
@@ -64,7 +64,6 @@ def build_generate_tab() -> dict[str, gr.components.Component]:
|
|
| 64 |
label="Output",
|
| 65 |
type="filepath",
|
| 66 |
interactive=False,
|
| 67 |
-
show_download_button=True,
|
| 68 |
)
|
| 69 |
components["output_meta"] = gr.Code(
|
| 70 |
label="Metadata",
|
|
|
|
| 64 |
label="Output",
|
| 65 |
type="filepath",
|
| 66 |
interactive=False,
|
|
|
|
| 67 |
)
|
| 68 |
components["output_meta"] = gr.Code(
|
| 69 |
label="Metadata",
|