Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -244,6 +244,9 @@ def generate_audio(text, cond_loudness, cond_pitch, cond_events):
|
|
| 244 |
# -----------------------------
|
| 245 |
blue_theme = gr.themes.Soft(primary_hue="blue", secondary_hue="sky", neutral_hue="slate")
|
| 246 |
|
|
|
|
|
|
|
|
|
|
| 247 |
CAPTION_PLACEHOLDER = 'Water flows and dishes clatter with child speech and laughter.'
|
| 248 |
|
| 249 |
EVENTS_PLACEHOLDER = '''
|
|
@@ -273,13 +276,14 @@ with gr.Blocks(theme=blue_theme, title="Audio ControlNet – Text to Audio") as
|
|
| 273 |
label="Text Prompt",
|
| 274 |
placeholder=CAPTION_PLACEHOLDER,
|
| 275 |
lines=4,
|
|
|
|
| 276 |
)
|
| 277 |
|
| 278 |
with gr.Tabs() as tabs:
|
| 279 |
with gr.Tab("Sound Events") as tab_events:
|
| 280 |
with gr.Row():
|
| 281 |
with gr.Column(scale=1):
|
| 282 |
-
sound_events = gr.Textbox(label="Sound Events (JSON)", placeholder=EVENTS_PLACEHOLDER, lines=8)
|
| 283 |
random_example_btn = gr.Button("🎲 Random Example", variant="primary", size="sm")
|
| 284 |
with gr.Column(scale=1):
|
| 285 |
events_plot = gr.Plot(label="Sound Events Roll", elem_classes="plot-small")
|
|
@@ -307,6 +311,9 @@ with gr.Blocks(theme=blue_theme, title="Audio ControlNet – Text to Audio") as
|
|
| 307 |
pitch_audio.change(fn=extract_pitch, inputs=pitch_audio, outputs=pitch_plot)
|
| 308 |
sound_events.change(fn=visualize_events, inputs=sound_events, outputs=events_plot)
|
| 309 |
|
|
|
|
|
|
|
|
|
|
| 310 |
# Random example button event
|
| 311 |
random_example_btn.click(
|
| 312 |
fn=generate_random_example,
|
|
|
|
| 244 |
# -----------------------------
|
| 245 |
blue_theme = gr.themes.Soft(primary_hue="blue", secondary_hue="sky", neutral_hue="slate")
|
| 246 |
|
| 247 |
+
# Generate initial random example for page load
|
| 248 |
+
initial_caption, initial_events = generate_random_example()
|
| 249 |
+
|
| 250 |
CAPTION_PLACEHOLDER = 'Water flows and dishes clatter with child speech and laughter.'
|
| 251 |
|
| 252 |
EVENTS_PLACEHOLDER = '''
|
|
|
|
| 276 |
label="Text Prompt",
|
| 277 |
placeholder=CAPTION_PLACEHOLDER,
|
| 278 |
lines=4,
|
| 279 |
+
value=initial_caption,
|
| 280 |
)
|
| 281 |
|
| 282 |
with gr.Tabs() as tabs:
|
| 283 |
with gr.Tab("Sound Events") as tab_events:
|
| 284 |
with gr.Row():
|
| 285 |
with gr.Column(scale=1):
|
| 286 |
+
sound_events = gr.Textbox(label="Sound Events (JSON)", placeholder=EVENTS_PLACEHOLDER, lines=8, value=initial_events)
|
| 287 |
random_example_btn = gr.Button("🎲 Random Example", variant="primary", size="sm")
|
| 288 |
with gr.Column(scale=1):
|
| 289 |
events_plot = gr.Plot(label="Sound Events Roll", elem_classes="plot-small")
|
|
|
|
| 311 |
pitch_audio.change(fn=extract_pitch, inputs=pitch_audio, outputs=pitch_plot)
|
| 312 |
sound_events.change(fn=visualize_events, inputs=sound_events, outputs=events_plot)
|
| 313 |
|
| 314 |
+
# Initialize events plot with the initial random example
|
| 315 |
+
demo.load(fn=lambda: visualize_events(initial_events), inputs=[], outputs=events_plot)
|
| 316 |
+
|
| 317 |
# Random example button event
|
| 318 |
random_example_btn.click(
|
| 319 |
fn=generate_random_example,
|