AndreasXi commited on
Commit
6a37b4f
·
1 Parent(s): 3235b3a

update web

Browse files
Files changed (1) hide show
  1. app.py +337 -255
app.py CHANGED
@@ -148,14 +148,6 @@ def generate_audio_gradio(
148
  return x
149
  audio = fade_out(audio, seq_cfg.sampling_rate)
150
 
151
- # text_embed = laion_clap_model.get_text_embedding(prompt, use_tensor=True).squeeze()
152
- # audio_embed = laion_clap_model.get_audio_embedding_from_data(audios[:,0,:].float().cpu(), use_tensor=True).squeeze()
153
- # scores = torch.cosine_similarity(text_embed.expand(audio_embed.shape[0], -1),
154
- # audio_embed,
155
- # dim=-1)
156
- # log.info(scores)
157
- # log.info(torch.argmax(scores).item())
158
- # audio = audios[torch.argmax(scores).item()].float().cpu()
159
  safe_prompt = (
160
  "".join(c for c in prompt if c.isalnum() or c in (" ", "_"))
161
  .rstrip()
@@ -175,254 +167,344 @@ def generate_audio_gradio(
175
  str(save_path),
176
  )
177
 
178
- theme = gr.themes.Soft(
179
- primary_hue="blue",
180
- secondary_hue="slate",
181
- neutral_hue="slate",
182
- text_size="sm",
183
- spacing_size="sm",
184
- ).set(
185
- background_fill_primary="*neutral_50",
186
- background_fill_secondary="*background_fill_primary",
187
- block_background_fill="*background_fill_primary",
188
- block_border_width="0px",
189
- panel_background_fill="*neutral_50",
190
- panel_border_width="0px",
191
- input_background_fill="*neutral_100",
192
- input_border_color="*neutral_200",
193
- button_primary_background_fill="*primary_300",
194
- button_primary_background_fill_hover="*primary_400",
195
- button_secondary_background_fill="*neutral_200",
196
- button_secondary_background_fill_hover="*neutral_300",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  )
198
- custom_css = """
199
- #main-headertitle {
200
- text-align: center;
201
- margin-top: 15px;
202
- margin-bottom: 10px;
203
- color: var(--neutral-600);
204
- font-weight: 600;
205
- }
206
- #main-header {
207
- text-align: center;
208
- margin-top: 5px;
209
- margin-bottom: 10px;
210
- color: var(--neutral-600);
211
- font-weight: 600;
212
- }
213
- #model-settings-header, #generation-settings-header {
214
- color: var(--neutral-600);
215
- margin-top: 8px;
216
- margin-bottom: 8px;
217
- font-weight: 500;
218
- font-size: 1.1em;
219
- }
220
- .setting-section {
221
- padding: 10px 12px;
222
- border-radius: 6px;
223
- background-color: var(--neutral-50);
224
- margin-bottom: 10px;
225
- border: 1px solid var(--neutral-100);
226
- }
227
- hr {
228
- border: none;
229
- height: 1px;
230
- background-color: var(--neutral-200);
231
- margin: 8px 0;
232
- }
233
- #generate-btn {
234
- width: 100%;
235
- max-width: 250px;
236
- margin: 10px auto;
237
- display: block;
238
- padding: 10px 15px;
239
- font-size: 16px;
240
- border-radius: 5px;
241
- }
242
- #status-box {
243
- min-height: 50px;
244
- display: flex;
245
- align-items: center;
246
- justify-content: center;
247
- padding: 8px;
248
- border-radius: 5px;
249
- border: 1px solid var(--neutral-200);
250
- color: var(--neutral-700);
251
- }
252
- #project-badges {
253
- text-align: center;
254
- margin-top: 30px;
255
- margin-bottom: 20px;
256
- }
257
- #project-badges #badge-container {
258
- display: flex;
259
- gap: 10px;
260
- align-items: center;
261
- justify-content: center;
262
- flex-wrap: wrap;
263
- }
264
- #project-badges img {
265
- border-radius: 5px;
266
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
267
- height: 20px;
268
- transition: transform 0.1s ease, box-shadow 0.1s ease;
269
- }
270
- #project-badges a:hover img {
271
- transform: translateY(-2px);
272
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
273
- }
274
- #audio-output {
275
- height: 200px;
276
- border-radius: 5px;
277
- border: 1px solid var(--neutral-200);
278
- }
279
- .gradio-dropdown label, .gradio-checkbox label, .gradio-number label, .gradio-textbox label {
280
- font-weight: 500;
281
- color: var(--neutral-700);
282
- font-size: 0.9em;
283
- }
284
- .gradio-row {
285
- gap: 8px;
286
- }
287
- .gradio-block {
288
- margin-bottom: 8px;
289
- }
290
- .setting-section .gradio-block {
291
- margin-bottom: 6px;
292
- }
293
- ::-webkit-scrollbar {
294
- width: 8px;
295
- height: 8px;
296
- }
297
- ::-webkit-scrollbar-track {
298
- background: var(--neutral-100);
299
- border-radius: 4px;
300
- }
301
- ::-webkit-scrollbar-thumb {
302
- background: var(--neutral-300);
303
- border-radius: 4px;
304
- }
305
- ::-webkit-scrollbar-thumb:hover {
306
- background: var(--neutral-400);
307
- }
308
- * {
309
- scrollbar-width: thin;
310
- scrollbar-color: var(--neutral-300) var(--neutral-100);
311
- }
312
- """
313
- with gr.Blocks(title="MeanAudio Generator", theme=theme, css=custom_css) as demo:
314
- gr.Markdown("# MeanAudio: Fast and Faithful Text-to-Audio Generation with Mean Flows", elem_id="main-header")
315
- badge_html = '''
316
- <div id="project-badges"> <!-- 使用 ID
317
- 以便应用 CSS -->
318
- <div id="badge-container"> <!-- 添加这个容器 div 并使用 ID -->
319
- <a href="https://huggingface.co/junxiliu/MeanAudio">
320
- <img src="https://img.shields.io/badge/Model-HuggingFace-violet?logo=huggingface" alt="Hugging Face Model">
321
- </a>
322
- <a href="https://huggingface.co/spaces/chenxie95/MeanAudio">
323
- <img src="https://img.shields.io/badge/Space-HuggingFace-8A2BE2?logo=huggingface" alt="Hugging Face Space">
324
- </a>
325
- <a href="https://meanaudio.github.io/">
326
- <img src="https://img.shields.io/badge/Project-Page-brightred?style=flat" alt="Project Page">
327
- </a>
328
- <a href="https://github.com/xiquan-li/MeanAudio">
329
- <img src="https://img.shields.io/badge/Code-GitHub-black?logo=github" alt="GitHub">
330
- </a>
331
- </div>
332
- </div>
333
- '''
334
- gr.HTML(badge_html)
335
- with gr.Column(elem_classes="setting-section"):
336
- with gr.Row():
337
- available_variants = (
338
- list(all_model_cfg.keys()) if all_model_cfg else []
339
- )
340
- default_variant = (
341
- 'meanaudio_mf'
342
- )
343
- variant = gr.Dropdown(
344
- label="Model Variant",
345
- choices=available_variants,
346
- value=default_variant,
347
- interactive=True,
348
- scale=3,
349
- )
350
- with gr.Column(elem_classes="setting-section"):
351
- with gr.Row():
352
- prompt = gr.Textbox(
353
- label="Prompt",
354
- placeholder="Describe the sound you want to generate...",
355
- scale=1,
356
- )
357
- negative_prompt = gr.Textbox(
358
- label="Negative Prompt",
359
- placeholder="Describe sounds you want to avoid...",
360
- value="",
361
- scale=1,
362
- )
363
- with gr.Row():
364
- duration = gr.Number(
365
- label="Duration (sec)", value=10.0, minimum=0.1, scale=1
366
- )
367
- cfg_strength = gr.Number(
368
- label="CFG (Meanflow forced to 3)", value=3, minimum=0.0, scale=1
369
- )
370
- with gr.Row():
371
- seed = gr.Number(
372
- label="Seed (-1 for random)", value=42, precision=0, scale=1
373
- )
374
- num_steps = gr.Number(
375
- label="Number of Steps",
376
- value=1,
377
- precision=0,
378
- minimum=1,
379
- scale=1,
380
- )
381
- generate_button = gr.Button("Generate", variant="primary", elem_id="generate-btn")
382
- generate_output_text = gr.Textbox(
383
- label="Result Status", interactive=False, elem_id="status-box"
384
- )
385
- audio_output = gr.Audio(
386
- label="Generated Audio", type="filepath", elem_id="audio-output"
387
- )
388
- generate_button.click(
389
- fn=generate_audio_gradio,
390
- inputs=[
391
- prompt,
392
- negative_prompt,
393
- duration,
394
- cfg_strength,
395
- num_steps,
396
- seed,
397
- variant,
398
- ],
399
- outputs=[generate_output_text, audio_output],
400
- )
401
- audio_examples = [
402
- ["Typing on a keyboard", "", 10.0, 3, 1, 42, "meanaudio_mf"],
403
- ["A man speaks followed by a popping noise and laughter", "", 10.0, 3, 1, 42, "meanaudio_mf"],
404
- ["Some humming followed by a toilet flushing", "", 10.0, 3, 2, 42, "meanaudio_mf"],
405
- ["Rain falling on a hard surface as thunder roars in the distance", "", 10.0, 3, 5, 42, "meanaudio_mf"],
406
- ["Food sizzling and oil popping", "", 10.0, 3, 25, 42, "meanaudio_mf"],
407
- ["Pots and dishes clanking as a man talks followed by liquid pouring into a container", "", 8.0, 3, 2, 42, "meanaudio_mf"],
408
- ["A few seconds of silence then a rasping sound against wood", "", 12.0, 3, 2, 42, "meanaudio_mf"],
409
- ["A man speaks as he gives a speech and then the crowd cheers", "", 10.0, 3, 25, 42, "fluxaudio_fm"],
410
- ["A goat bleating repeatedly", "", 10.0, 3, 50, 123, "fluxaudio_fm"],
411
- ["A speech and gunfire followed by a gun being loaded", "", 10.0, 3, 1, 42, "meanaudio_mf"],
412
- ["Tires squealing followed by an engine revving", "", 12.0, 4, 25, 456, "fluxaudio_fm"],
413
- ["Hammer slowly hitting the wooden table", "", 10.0, 3.5, 25, 42, "fluxaudio_fm"],
414
- ["Dog barking excitedly and man shouting as race car engine roars past", "", 10.0, 3, 1, 42, "meanaudio_mf"],
415
- ["A dog barking and a cat mewing and a racing car passes by", "", 12.0, 3, 5, -1, "meanaudio_mf"],
416
- ["Whistling with birds chirping", "", 10.0, 4, 50, 42, "fluxaudio_fm"],
417
- ]
418
- gr.Examples(
419
- examples=audio_examples,
420
- inputs=[prompt, negative_prompt, duration, cfg_strength, num_steps, seed, variant],
421
- #outputs=[generate_output_text, audio_output],
422
- #fn=generate_audio_gradio,
423
- examples_per_page=5,
424
- label="Example Prompts",
425
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
 
427
  if __name__ == "__main__":
428
  demo.launch()
 
148
  return x
149
  audio = fade_out(audio, seq_cfg.sampling_rate)
150
 
 
 
 
 
 
 
 
 
151
  safe_prompt = (
152
  "".join(c for c in prompt if c.isalnum() or c in (" ", "_"))
153
  .rstrip()
 
167
  str(save_path),
168
  )
169
 
170
+
171
+ # Gradio input and output components
172
+ input_text = gr.Textbox(lines=2, label="Prompt")
173
+ output_audio = gr.Audio(label="Generated Audio", type="filepath")
174
+ denoising_steps = gr.Slider(minimum=1, maximum=50, value=1, step=5, label="Steps", interactive=True)
175
+ cfg_strength = gr.Slider(minimum=1, maximum=10, value=4.5, step=0.5, label="Guidance Scale (For MeanAudio, it is forced to 3 as integrated in training)", interactive=True)
176
+ duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Duration", interactive=True)
177
+ seed = gr.Slider(minimum=-1, maximum=1000000, value=42, step=1, label="Seed", interactive=True)
178
+ variant = gr.Dropdown(label="Model Variant", choices=list(all_model_cfg.keys()), value='meanaudio_s_full', interactive=True)
179
+
180
+ gr_interface = gr.Interface(
181
+ fn=generate_audio_gradio,
182
+ inputs=[input_text, None, duration, cfg_strength, denoising_steps, seed, variant],
183
+ outputs=["text", "audio"],
184
+ title="TangoFlux: Super Fast and Faithful Text to Audio Generation with Flow Matching and Clap-Ranked Preference Optimization",
185
+ description="",
186
+ allow_flagging=False,
187
+ examples=[
188
+ ["Generate the festive sounds of a fireworks show: explosions lighting up the sky, crowd cheering, and the faint music playing in the background!! Celebration of the new year!"],
189
+ ["Melodic human whistling harmonizing with natural birdsong"],
190
+ ["A parade marches through a town square, with drumbeats pounding, children clapping, and a horse neighing amidst the commotion"],
191
+ ["Quiet speech and then and airplane flying away"],
192
+ ["A soccer ball hits a goalpost with a metallic clang, followed by cheers, clapping, and the distant hum of a commentator’s voice"],
193
+ ["A basketball bounces rhythmically on a court, shoes squeak against the floor, and a referee’s whistle cuts through the air"],
194
+ ["Dripping water echoes sharply, a distant growl reverberates through the cavern, and soft scraping metal suggests something lurking unseen"],
195
+ ["A cow is mooing whilst a lion is roaring in the background as a hunter shoots. A flock of birds subsequently fly away from the trees."],
196
+ ["The deep growl of an alligator ripples through the swamp as reeds sway with a soft rustle and a turtle splashes into the murky water"],
197
+ ["Gentle female voice cooing and baby responding with happy gurgles and giggles"],
198
+ ['doorbell ding once followed by footsteps gradually getting louder and a door is opened '],
199
+ ["A fork scrapes a plate, water drips slowly into a sink, and the faint hum of a refrigerator lingers in the background"],
200
+ ["Powerful ocean waves crashing and receding on sandy beach with distant seagulls"],
201
+ ["Emulate the lively sounds of a retro arcade: 8-bit game music, coins clinking. People cheering occasionally when players winning"],
202
+ ["Simulate a forest ambiance with birds chirping and wind rustling through the leaves"],
203
+ ["A train conductor blows a sharp whistle, metal wheels screech on the rails, and passengers murmur while settling into their seats"],
204
+ ["Generate an energetic and bustling city street scene with distant traffic and close conversations"],
205
+ ["Alarms blare with rising urgency as fragments clatter against a metallic hull, interrupted by a faint hiss of escaping air"],
206
+ ["Create a serene soundscape of a quiet beach at sunset"],
207
+ ["Tiny pops and hisses of chemical reactions intermingle with the rhythmic pumping of a centrifuge and the soft whirr of air filtration"],
208
+ ["A train conductor blows a sharp whistle, metal wheels screech on the rails, and passengers murmur while settling into their seats"],
209
+ ["Emulate the lively sounds of a retro arcade: 8-bit game music, coins clinking. People cheering occasionally when players winning"],
210
+ ["Quiet whispered conversation gradually fading into distant jet engine roar diminishing into silence"],
211
+ ["Clear sound of bicycle tires crunching on loose gravel and dirt, followed by deep male laughter echoing"],
212
+ ["Multiple ducks quacking loudly with splashing water and piercing wild animal shriek in background"],
213
+ ["Create the underwater soundscape: gentle waves, faint whale calls, and the occasional clink of scuba gear"],
214
+ ["Recreate the sounds of an active volcano: rumbling earth, lava bubbling, and the occasional loud explosive roar of an eruption"],
215
+ ["A pile of coins spills onto a wooden table with a metallic clatter, followed by the hushed murmur of a tavern crowd and the creak of a swinging door"],
216
+ ["Clear male voice speaking, sharp popping sound, followed by genuine group laughter"],
217
+ ["Stream of water hitting empty ceramic cup, pitch rising as cup fills up"],
218
+ ["Massive crowd erupting in thunderous applause and excited cheering"],
219
+ ["Deep rolling thunder with bright lightning strikes crackling through sky"],
220
+ ["Aggressive dog barking and distressed cat meowing as racing car roars past at high speed"],
221
+ ["Peaceful stream bubbling and birds singing, interrupted by sudden explosive gunshot"],
222
+ ["Man speaking outdoors, goat bleating loudly, metal gate scraping closed, ducks quacking frantically, wind howling into microphone"],
223
+ ["Series of loud aggressive dog barks echoing"],
224
+ ["Multiple distinct cat meows at different pitches"],
225
+ ["Rhythmic wooden table tapping overlaid with steady water pouring sound"],
226
+ ["Sustained crowd applause with camera clicks and amplified male announcer voice"],
227
+ ["Two sharp gunshots followed by panicked birds taking flight with rapid wing flaps"],
228
+ ["Deep rhythmic snoring with clear breathing patterns"],
229
+ ["Multiple racing engines revving and accelerating with sharp whistle piercing through"],
230
+ ["Massive stadium crowd cheering as thunder crashes and lightning strikes"],
231
+ ["Heavy helicopter blades chopping through air with engine and wind noise"],
232
+ ["Dog barking excitedly and man shouting as race car engine roars past"],
233
+ ["A bicycle peddling on dirt and gravel followed by a man speaking then laughing"],
234
+ ["Ducks quack and water splashes with some animal screeching in the background"],
235
+ ["Describe the sound of the ocean"],
236
+ ["A woman and a baby are having a conversation"],
237
+ ["A man speaks followed by a popping noise and laughter"],
238
+ ["A cup is filled from a faucet"],
239
+ ["An audience cheering and clapping"],
240
+ ["Rolling thunder with lightning strikes"],
241
+ ["A dog barking and a cat mewing and a racing car passes by"],
242
+ ["Gentle water stream, birds chirping and sudden gun shot"],
243
+ ["A dog barking"],
244
+ ["A cat meowing"],
245
+ ["Wooden table tapping sound while water pouring"],
246
+ ["Applause from a crowd with distant clicking and a man speaking over a loudspeaker"],
247
+ ["two gunshots followed by birds flying away while chirping"],
248
+ ["Whistling with birds chirping"],
249
+ ["A person snoring"],
250
+ ["Motor vehicles are driving with loud engines and a person whistles"],
251
+ ["People cheering in a stadium while thunder and lightning strikes"],
252
+ ["A helicopter is in flight"],
253
+ ["A dog barking and a man talking and a racing car passes by"],
254
+ ],
255
+ cache_examples="lazy", # Turn on to cache.
256
  )
257
+
258
+
259
+
260
+ # theme = gr.themes.Soft(
261
+ # primary_hue="blue",
262
+ # secondary_hue="slate",
263
+ # neutral_hue="slate",
264
+ # text_size="sm",
265
+ # spacing_size="sm",
266
+ # ).set(
267
+ # background_fill_primary="*neutral_50",
268
+ # background_fill_secondary="*background_fill_primary",
269
+ # block_background_fill="*background_fill_primary",
270
+ # block_border_width="0px",
271
+ # panel_background_fill="*neutral_50",
272
+ # panel_border_width="0px",
273
+ # input_background_fill="*neutral_100",
274
+ # input_border_color="*neutral_200",
275
+ # button_primary_background_fill="*primary_300",
276
+ # button_primary_background_fill_hover="*primary_400",
277
+ # button_secondary_background_fill="*neutral_200",
278
+ # button_secondary_background_fill_hover="*neutral_300",
279
+ # )
280
+ # custom_css = """
281
+ # #main-headertitle {
282
+ # text-align: center;
283
+ # margin-top: 15px;
284
+ # margin-bottom: 10px;
285
+ # color: var(--neutral-600);
286
+ # font-weight: 600;
287
+ # }
288
+ # #main-header {
289
+ # text-align: center;
290
+ # margin-top: 5px;
291
+ # margin-bottom: 10px;
292
+ # color: var(--neutral-600);
293
+ # font-weight: 600;
294
+ # }
295
+ # #model-settings-header, #generation-settings-header {
296
+ # color: var(--neutral-600);
297
+ # margin-top: 8px;
298
+ # margin-bottom: 8px;
299
+ # font-weight: 500;
300
+ # font-size: 1.1em;
301
+ # }
302
+ # .setting-section {
303
+ # padding: 10px 12px;
304
+ # border-radius: 6px;
305
+ # background-color: var(--neutral-50);
306
+ # margin-bottom: 10px;
307
+ # border: 1px solid var(--neutral-100);
308
+ # }
309
+ # hr {
310
+ # border: none;
311
+ # height: 1px;
312
+ # background-color: var(--neutral-200);
313
+ # margin: 8px 0;
314
+ # }
315
+ # #generate-btn {
316
+ # width: 100%;
317
+ # max-width: 250px;
318
+ # margin: 10px auto;
319
+ # display: block;
320
+ # padding: 10px 15px;
321
+ # font-size: 16px;
322
+ # border-radius: 5px;
323
+ # }
324
+ # #status-box {
325
+ # min-height: 50px;
326
+ # display: flex;
327
+ # align-items: center;
328
+ # justify-content: center;
329
+ # padding: 8px;
330
+ # border-radius: 5px;
331
+ # border: 1px solid var(--neutral-200);
332
+ # color: var(--neutral-700);
333
+ # }
334
+ # #project-badges {
335
+ # text-align: center;
336
+ # margin-top: 30px;
337
+ # margin-bottom: 20px;
338
+ # }
339
+ # #project-badges #badge-container {
340
+ # display: flex;
341
+ # gap: 10px;
342
+ # align-items: center;
343
+ # justify-content: center;
344
+ # flex-wrap: wrap;
345
+ # }
346
+ # #project-badges img {
347
+ # border-radius: 5px;
348
+ # box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
349
+ # height: 20px;
350
+ # transition: transform 0.1s ease, box-shadow 0.1s ease;
351
+ # }
352
+ # #project-badges a:hover img {
353
+ # transform: translateY(-2px);
354
+ # box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
355
+ # }
356
+ # #audio-output {
357
+ # height: 200px;
358
+ # border-radius: 5px;
359
+ # border: 1px solid var(--neutral-200);
360
+ # }
361
+ # .gradio-dropdown label, .gradio-checkbox label, .gradio-number label, .gradio-textbox label {
362
+ # font-weight: 500;
363
+ # color: var(--neutral-700);
364
+ # font-size: 0.9em;
365
+ # }
366
+ # .gradio-row {
367
+ # gap: 8px;
368
+ # }
369
+ # .gradio-block {
370
+ # margin-bottom: 8px;
371
+ # }
372
+ # .setting-section .gradio-block {
373
+ # margin-bottom: 6px;
374
+ # }
375
+ # ::-webkit-scrollbar {
376
+ # width: 8px;
377
+ # height: 8px;
378
+ # }
379
+ # ::-webkit-scrollbar-track {
380
+ # background: var(--neutral-100);
381
+ # border-radius: 4px;
382
+ # }
383
+ # ::-webkit-scrollbar-thumb {
384
+ # background: var(--neutral-300);
385
+ # border-radius: 4px;
386
+ # }
387
+ # ::-webkit-scrollbar-thumb:hover {
388
+ # background: var(--neutral-400);
389
+ # }
390
+ # * {
391
+ # scrollbar-width: thin;
392
+ # scrollbar-color: var(--neutral-300) var(--neutral-100);
393
+ # }
394
+ # """
395
+ # with gr.Blocks(title="MeanAudio Generator", theme=theme, css=custom_css) as demo:
396
+ # gr.Markdown("# MeanAudio: Fast and Faithful Text-to-Audio Generation with Mean Flows", elem_id="main-header")
397
+ # badge_html = '''
398
+ # <div id="project-badges"> <!-- 使用 ID
399
+ # 以便应用 CSS -->
400
+ # <div id="badge-container"> <!-- 添加这个容器 div 并使用 ID -->
401
+ # <a href="https://huggingface.co/junxiliu/MeanAudio">
402
+ # <img src="https://img.shields.io/badge/Model-HuggingFace-violet?logo=huggingface" alt="Hugging Face Model">
403
+ # </a>
404
+ # <a href="https://huggingface.co/spaces/chenxie95/MeanAudio">
405
+ # <img src="https://img.shields.io/badge/Space-HuggingFace-8A2BE2?logo=huggingface" alt="Hugging Face Space">
406
+ # </a>
407
+ # <a href="https://meanaudio.github.io/">
408
+ # <img src="https://img.shields.io/badge/Project-Page-brightred?style=flat" alt="Project Page">
409
+ # </a>
410
+ # <a href="https://github.com/xiquan-li/MeanAudio">
411
+ # <img src="https://img.shields.io/badge/Code-GitHub-black?logo=github" alt="GitHub">
412
+ # </a>
413
+ # </div>
414
+ # </div>
415
+ # '''
416
+ # gr.HTML(badge_html)
417
+ # with gr.Column(elem_classes="setting-section"):
418
+ # with gr.Row():
419
+ # available_variants = (
420
+ # list(all_model_cfg.keys()) if all_model_cfg else []
421
+ # )
422
+ # default_variant = (
423
+ # 'meanaudio_mf'
424
+ # )
425
+ # variant = gr.Dropdown(
426
+ # label="Model Variant",
427
+ # choices=available_variants,
428
+ # value=default_variant,
429
+ # interactive=True,
430
+ # scale=3,
431
+ # )
432
+ # with gr.Column(elem_classes="setting-section"):
433
+ # with gr.Row():
434
+ # prompt = gr.Textbox(
435
+ # label="Prompt",
436
+ # placeholder="Describe the sound you want to generate...",
437
+ # scale=1,
438
+ # )
439
+ # negative_prompt = gr.Textbox(
440
+ # label="Negative Prompt",
441
+ # placeholder="Describe sounds you want to avoid...",
442
+ # value="",
443
+ # scale=1,
444
+ # )
445
+ # with gr.Row():
446
+ # duration = gr.Number(
447
+ # label="Duration (sec)", value=10.0, minimum=0.1, scale=1
448
+ # )
449
+ # cfg_strength = gr.Number(
450
+ # label="CFG (Meanflow forced to 3)", value=3, minimum=0.0, scale=1
451
+ # )
452
+ # with gr.Row():
453
+ # seed = gr.Number(
454
+ # label="Seed (-1 for random)", value=42, precision=0, scale=1
455
+ # )
456
+ # num_steps = gr.Number(
457
+ # label="Number of Steps",
458
+ # value=1,
459
+ # precision=0,
460
+ # minimum=1,
461
+ # scale=1,
462
+ # )
463
+ # generate_button = gr.Button("Generate", variant="primary", elem_id="generate-btn")
464
+ # generate_output_text = gr.Textbox(
465
+ # label="Result Status", interactive=False, elem_id="status-box"
466
+ # )
467
+ # audio_output = gr.Audio(
468
+ # label="Generated Audio", type="filepath", elem_id="audio-output"
469
+ # )
470
+ # generate_button.click(
471
+ # fn=generate_audio_gradio,
472
+ # inputs=[
473
+ # prompt,
474
+ # negative_prompt,
475
+ # duration,
476
+ # cfg_strength,
477
+ # num_steps,
478
+ # seed,
479
+ # variant,
480
+ # ],
481
+ # outputs=[generate_output_text, audio_output],
482
+ # )
483
+ # audio_examples = [
484
+ # ["Typing on a keyboard", "", 10.0, 3, 1, 42, "meanaudio_mf"],
485
+ # ["A man speaks followed by a popping noise and laughter", "", 10.0, 3, 1, 42, "meanaudio_mf"],
486
+ # ["Some humming followed by a toilet flushing", "", 10.0, 3, 2, 42, "meanaudio_mf"],
487
+ # ["Rain falling on a hard surface as thunder roars in the distance", "", 10.0, 3, 5, 42, "meanaudio_mf"],
488
+ # ["Food sizzling and oil popping", "", 10.0, 3, 25, 42, "meanaudio_mf"],
489
+ # ["Pots and dishes clanking as a man talks followed by liquid pouring into a container", "", 8.0, 3, 2, 42, "meanaudio_mf"],
490
+ # ["A few seconds of silence then a rasping sound against wood", "", 12.0, 3, 2, 42, "meanaudio_mf"],
491
+ # ["A man speaks as he gives a speech and then the crowd cheers", "", 10.0, 3, 25, 42, "fluxaudio_fm"],
492
+ # ["A goat bleating repeatedly", "", 10.0, 3, 50, 123, "fluxaudio_fm"],
493
+ # ["A speech and gunfire followed by a gun being loaded", "", 10.0, 3, 1, 42, "meanaudio_mf"],
494
+ # ["Tires squealing followed by an engine revving", "", 12.0, 4, 25, 456, "fluxaudio_fm"],
495
+ # ["Hammer slowly hitting the wooden table", "", 10.0, 3.5, 25, 42, "fluxaudio_fm"],
496
+ # ["Dog barking excitedly and man shouting as race car engine roars past", "", 10.0, 3, 1, 42, "meanaudio_mf"],
497
+ # ["A dog barking and a cat mewing and a racing car passes by", "", 12.0, 3, 5, -1, "meanaudio_mf"],
498
+ # ["Whistling with birds chirping", "", 10.0, 4, 50, 42, "fluxaudio_fm"],
499
+ # ]
500
+ # gr.Examples(
501
+ # examples=audio_examples,
502
+ # inputs=[prompt, negative_prompt, duration, cfg_strength, num_steps, seed, variant],
503
+ # #outputs=[generate_output_text, audio_output],
504
+ # #fn=generate_audio_gradio,
505
+ # examples_per_page=5,
506
+ # label="Example Prompts",
507
+ # )
508
 
509
  if __name__ == "__main__":
510
  demo.launch()