Spaces:
Running
on
Zero
Running
on
Zero
| """ | |
| Simplified UI for ACE-Step API-focused usage | |
| """ | |
| import gradio as gr | |
| # Simplified presets - only EDM and Synth | |
| SIMPLE_PRESETS = { | |
| "EDM": "edm", | |
| "Synth": "synth" | |
| } | |
| def create_simple_ui(text2music_process_func): | |
| """Create a minimal UI for API usage""" | |
| with gr.Blocks(title="ACE Music Generator") as demo: | |
| gr.Markdown( | |
| """ | |
| <h1 style="text-align: center;">ACE Music Generator</h1> | |
| <p style="text-align: center;">Simple interface for music generation API</p> | |
| """ | |
| ) | |
| with gr.Row(): | |
| with gr.Column(): | |
| # Duration selection - only 20, 30, 60 seconds | |
| duration = gr.Radio( | |
| choices=[20, 30, 60], | |
| value=20, | |
| label="Duration (seconds)", | |
| type="value" | |
| ) | |
| # Preset selection - only EDM and Synth | |
| preset = gr.Radio( | |
| choices=list(SIMPLE_PRESETS.keys()), | |
| value="EDM", | |
| label="Preset", | |
| type="value" | |
| ) | |
| generate_btn = gr.Button("Generate", variant="primary") | |
| with gr.Column(): | |
| output_audio = gr.Audio(type="filepath", label="Generated Music") | |
| with gr.Accordion("Generation Info", open=False): | |
| output_info = gr.JSON(label="Parameters Used") | |
| def process_simple(duration, preset): | |
| # Get the tags for the selected preset | |
| tags = SIMPLE_PRESETS[preset] | |
| # Call the process function with all defaults except duration and tags | |
| result = text2music_process_func( | |
| audio_duration=float(duration), | |
| prompt=tags, | |
| lyrics="[instrumental]", # Always instrumental | |
| infer_step=60, | |
| guidance_scale=15.0, | |
| scheduler_type="euler", | |
| cfg_type="apg", | |
| omega_scale=10.0, | |
| manual_seeds=None, | |
| guidance_interval=0.5, | |
| guidance_interval_decay=0.0, | |
| min_guidance_scale=3.0, | |
| use_erg_tag=True, | |
| use_erg_lyric=False, | |
| use_erg_diffusion=True, | |
| oss_steps=None, | |
| guidance_scale_text=0.0, | |
| guidance_scale_lyric=0.0, | |
| audio2audio_enable=False, | |
| ref_audio_strength=0.5, | |
| ref_audio_input=None, | |
| lora_name_or_path="none" | |
| ) | |
| # Return audio and info | |
| if result and len(result) > 0: | |
| return result[0], result[-1] if len(result) > 1 else {} | |
| return None, {} | |
| generate_btn.click( | |
| fn=process_simple, | |
| inputs=[duration, preset], | |
| outputs=[output_audio, output_info], | |
| api_name="generate" # This makes it available as API endpoint | |
| ) | |
| return demo |