Spaces:
Running on Zero
Running on Zero
feat(ui): add generate tab builder with prompt/lyrics/duration/vocal mode
Browse files- tooltips.py +6 -0
- ui.py +74 -0
tooltips.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Centralised tooltip / `info=` strings — single source of truth."""
|
| 2 |
+
|
| 3 |
+
GENERATE_PROMPT = "Describe the song. Genre, instruments, tempo, mood."
|
| 4 |
+
GENERATE_LYRICS = "Use [verse] [chorus] [bridge] tags. Open the Lyrics tab to draft with Qwen 2.5."
|
| 5 |
+
GENERATE_DURATION = "Output length in seconds. Longer outputs cost more compute."
|
| 6 |
+
GENERATE_VOCAL = "With vocals: full song. Instrumental: no singing, just music."
|
ui.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Per-tab Gradio component builders + shared output panel.
|
| 2 |
+
|
| 3 |
+
Each builder returns a dict of components keyed by purpose so app.py wires
|
| 4 |
+
events without depending on Gradio's positional return order.
|
| 5 |
+
|
| 6 |
+
NOTE: builders DO NOT instantiate the surrounding gr.Group / pane — they
|
| 7 |
+
ONLY build the form + output components inside it. app.py wraps the
|
| 8 |
+
result in pane_generate / pane_cover / etc.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import gradio as gr
|
| 14 |
+
|
| 15 |
+
import tooltips
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def build_generate_tab() -> dict[str, gr.components.Component]:
|
| 19 |
+
"""Generate tab body: 2-column row (form left, output right).
|
| 20 |
+
|
| 21 |
+
LoRA / Advanced / LM-planner / DCW accordions are deferred to
|
| 22 |
+
M2-M4 and will be added by extending this builder.
|
| 23 |
+
"""
|
| 24 |
+
components: dict[str, gr.components.Component] = {}
|
| 25 |
+
|
| 26 |
+
with gr.Row():
|
| 27 |
+
# --- FORM column (left, ~60% width) ---
|
| 28 |
+
with gr.Column(scale=13):
|
| 29 |
+
components["prompt"] = gr.Textbox(
|
| 30 |
+
label="Style prompt",
|
| 31 |
+
placeholder="psytrance, rolling triplet bassline, acid squelch, metallic leads",
|
| 32 |
+
lines=2,
|
| 33 |
+
info=tooltips.GENERATE_PROMPT,
|
| 34 |
+
)
|
| 35 |
+
components["lyrics"] = gr.Textbox(
|
| 36 |
+
label="Lyrics",
|
| 37 |
+
placeholder="[intro] atmospheric pads\n[verse] ...",
|
| 38 |
+
lines=6,
|
| 39 |
+
info=tooltips.GENERATE_LYRICS,
|
| 40 |
+
)
|
| 41 |
+
with gr.Row():
|
| 42 |
+
components["duration_s"] = gr.Slider(
|
| 43 |
+
minimum=5,
|
| 44 |
+
maximum=240,
|
| 45 |
+
step=5,
|
| 46 |
+
value=30,
|
| 47 |
+
label="Duration (s)",
|
| 48 |
+
info=tooltips.GENERATE_DURATION,
|
| 49 |
+
)
|
| 50 |
+
components["instrumental"] = gr.Radio(
|
| 51 |
+
choices=["With vocals", "Instrumental"],
|
| 52 |
+
value="With vocals",
|
| 53 |
+
label="Vocal mode",
|
| 54 |
+
info=tooltips.GENERATE_VOCAL,
|
| 55 |
+
)
|
| 56 |
+
components["generate_btn"] = gr.Button(
|
| 57 |
+
"▶ Generate",
|
| 58 |
+
variant="primary",
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
# --- OUTPUT column (right, ~40% width) ---
|
| 62 |
+
with gr.Column(scale=10):
|
| 63 |
+
components["output_audio"] = gr.Audio(
|
| 64 |
+
label="Output",
|
| 65 |
+
type="filepath",
|
| 66 |
+
interactive=False,
|
| 67 |
+
show_download_button=True,
|
| 68 |
+
)
|
| 69 |
+
components["output_meta"] = gr.Code(
|
| 70 |
+
label="Metadata",
|
| 71 |
+
language="json",
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
return components
|