Spaces:
Running on Zero
Running on Zero
Manmay Nakhashi commited on
Commit ·
b2203ed
1
Parent(s): 9165469
Replace example dropdown with click-to-generate gr.Examples table
Browse filesStandard HF Space pattern: each example row has a name + the full
prompt; clicking auto-fills inputs and runs generation immediately
(run_on_click=True, cache_examples=False because GPU isn't available
at build time on ZeroGPU).
app.py
CHANGED
|
@@ -142,10 +142,6 @@ with gr.Blocks(
|
|
| 142 |
placeholder=EXAMPLES[0][1],
|
| 143 |
lines=6, elem_classes=["prompt-box"],
|
| 144 |
)
|
| 145 |
-
example_chooser = gr.Dropdown(
|
| 146 |
-
choices=[e[0] for e in EXAMPLES],
|
| 147 |
-
label="Load an example prompt", interactive=True, value=None,
|
| 148 |
-
)
|
| 149 |
audio_ref = gr.Audio(
|
| 150 |
label="Voice reference (optional, 10+ seconds)",
|
| 151 |
type="filepath",
|
|
@@ -171,21 +167,27 @@ with gr.Blocks(
|
|
| 171 |
"**Avoid inside quotes:** Ahem, Pfft, Sigh, Gasp, Cough — the model speaks them literally."
|
| 172 |
)
|
| 173 |
|
| 174 |
-
def _load_example(choice: str):
|
| 175 |
-
if not choice:
|
| 176 |
-
return gr.update()
|
| 177 |
-
for name, prompt in EXAMPLES:
|
| 178 |
-
if name == choice:
|
| 179 |
-
return prompt
|
| 180 |
-
return gr.update()
|
| 181 |
-
|
| 182 |
-
example_chooser.change(_load_example, inputs=[example_chooser], outputs=[prompt_box])
|
| 183 |
gen_btn.click(
|
| 184 |
on_generate,
|
| 185 |
inputs=[prompt_box, audio_ref, cfg_slider, stg_slider, dur_slider, seed_input],
|
| 186 |
outputs=[audio_out],
|
| 187 |
)
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
if __name__ == "__main__":
|
| 191 |
# HF Spaces routes external traffic to container port 7860 by default.
|
|
|
|
| 142 |
placeholder=EXAMPLES[0][1],
|
| 143 |
lines=6, elem_classes=["prompt-box"],
|
| 144 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
audio_ref = gr.Audio(
|
| 146 |
label="Voice reference (optional, 10+ seconds)",
|
| 147 |
type="filepath",
|
|
|
|
| 167 |
"**Avoid inside quotes:** Ahem, Pfft, Sigh, Gasp, Cough — the model speaks them literally."
|
| 168 |
)
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
gen_btn.click(
|
| 171 |
on_generate,
|
| 172 |
inputs=[prompt_box, audio_ref, cfg_slider, stg_slider, dur_slider, seed_input],
|
| 173 |
outputs=[audio_out],
|
| 174 |
)
|
| 175 |
|
| 176 |
+
# Click-to-run example table — fills inputs AND triggers generation.
|
| 177 |
+
gr.Examples(
|
| 178 |
+
label="Example prompts (click any row to generate)",
|
| 179 |
+
examples=[
|
| 180 |
+
[name, prompt, None, 2.5, 1.5, 1.1, 42]
|
| 181 |
+
for name, prompt in EXAMPLES
|
| 182 |
+
],
|
| 183 |
+
inputs=[gr.Textbox(visible=False), prompt_box, audio_ref,
|
| 184 |
+
cfg_slider, stg_slider, dur_slider, seed_input],
|
| 185 |
+
outputs=[audio_out],
|
| 186 |
+
fn=lambda _name, prompt, ref, cfg, stg, dur, seed: on_generate(prompt, ref, cfg, stg, dur, seed),
|
| 187 |
+
cache_examples=False,
|
| 188 |
+
run_on_click=True,
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
|
| 192 |
if __name__ == "__main__":
|
| 193 |
# HF Spaces routes external traffic to container port 7860 by default.
|