Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
2c1e8f3
1
Parent(s):
288fb45
simplify the UI while keeping defaults
Browse files- app.py +4 -5
- ui/simple_components.py +90 -0
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import argparse
|
| 2 |
-
from ui.
|
| 3 |
from pipeline_ace_step import ACEStepPipeline
|
| 4 |
from data_sampler import DataSampler
|
| 5 |
import os
|
|
@@ -82,10 +82,9 @@ def main(args):
|
|
| 82 |
return result[0] # Return first audio output (now always 24kHz WAV)
|
| 83 |
return None
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
load_data_func=data_sampler.load_json,
|
| 89 |
)
|
| 90 |
|
| 91 |
# Add API endpoint to the demo
|
|
|
|
| 1 |
import argparse
|
| 2 |
+
from ui.simple_components import create_simple_ui
|
| 3 |
from pipeline_ace_step import ACEStepPipeline
|
| 4 |
from data_sampler import DataSampler
|
| 5 |
import os
|
|
|
|
| 82 |
return result[0] # Return first audio output (now always 24kHz WAV)
|
| 83 |
return None
|
| 84 |
|
| 85 |
+
# Use simplified UI
|
| 86 |
+
demo = create_simple_ui(
|
| 87 |
+
text2music_process_func=model_demo.__call__
|
|
|
|
| 88 |
)
|
| 89 |
|
| 90 |
# Add API endpoint to the demo
|
ui/simple_components.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Simplified UI for ACE-Step API-focused usage
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import gradio as gr
|
| 6 |
+
|
| 7 |
+
# Simplified presets - only EDM and Synth
|
| 8 |
+
SIMPLE_PRESETS = {
|
| 9 |
+
"EDM": "edm, synth, bass, kick drum, 128 bpm, euphoric, pulsating, energetic, instrumental",
|
| 10 |
+
"Synth": "synth, electronic, ambient, atmospheric, 100 bpm, dreamy, ethereal, instrumental"
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
def create_simple_ui(text2music_process_func):
|
| 14 |
+
"""Create a minimal UI for API usage"""
|
| 15 |
+
|
| 16 |
+
with gr.Blocks(title="ACE Music Generator") as demo:
|
| 17 |
+
gr.Markdown(
|
| 18 |
+
"""
|
| 19 |
+
<h1 style="text-align: center;">ACE Music Generator</h1>
|
| 20 |
+
<p style="text-align: center;">Simple interface for music generation API</p>
|
| 21 |
+
"""
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
with gr.Row():
|
| 25 |
+
with gr.Column():
|
| 26 |
+
# Duration selection - only 20, 30, 60 seconds
|
| 27 |
+
duration = gr.Radio(
|
| 28 |
+
choices=[20, 30, 60],
|
| 29 |
+
value=20,
|
| 30 |
+
label="Duration (seconds)",
|
| 31 |
+
type="value"
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
# Preset selection - only EDM and Synth
|
| 35 |
+
preset = gr.Radio(
|
| 36 |
+
choices=list(SIMPLE_PRESETS.keys()),
|
| 37 |
+
value="EDM",
|
| 38 |
+
label="Preset",
|
| 39 |
+
type="value"
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
generate_btn = gr.Button("Generate", variant="primary")
|
| 43 |
+
|
| 44 |
+
with gr.Column():
|
| 45 |
+
output_audio = gr.Audio(type="filepath", label="Generated Music")
|
| 46 |
+
with gr.Accordion("Generation Info", open=False):
|
| 47 |
+
output_info = gr.JSON(label="Parameters Used")
|
| 48 |
+
|
| 49 |
+
def process_simple(duration, preset):
|
| 50 |
+
# Get the tags for the selected preset
|
| 51 |
+
tags = SIMPLE_PRESETS[preset]
|
| 52 |
+
|
| 53 |
+
# Call the process function with all defaults except duration and tags
|
| 54 |
+
result = text2music_process_func(
|
| 55 |
+
audio_duration=float(duration),
|
| 56 |
+
prompt=tags,
|
| 57 |
+
lyrics="[instrumental]", # Always instrumental
|
| 58 |
+
infer_step=60,
|
| 59 |
+
guidance_scale=15.0,
|
| 60 |
+
scheduler_type="euler",
|
| 61 |
+
cfg_type="apg",
|
| 62 |
+
omega_scale=10.0,
|
| 63 |
+
manual_seeds=None,
|
| 64 |
+
guidance_interval=0.5,
|
| 65 |
+
guidance_interval_decay=0.0,
|
| 66 |
+
min_guidance_scale=3.0,
|
| 67 |
+
use_erg_tag=True,
|
| 68 |
+
use_erg_lyric=False,
|
| 69 |
+
use_erg_diffusion=True,
|
| 70 |
+
oss_steps=None,
|
| 71 |
+
guidance_scale_text=0.0,
|
| 72 |
+
guidance_scale_lyric=0.0,
|
| 73 |
+
audio2audio_enable=False,
|
| 74 |
+
ref_audio_strength=0.5,
|
| 75 |
+
ref_audio_input=None,
|
| 76 |
+
lora_name_or_path="none"
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
# Return audio and info
|
| 80 |
+
if result and len(result) > 0:
|
| 81 |
+
return result[0], result[-1] if len(result) > 1 else {}
|
| 82 |
+
return None, {}
|
| 83 |
+
|
| 84 |
+
generate_btn.click(
|
| 85 |
+
fn=process_simple,
|
| 86 |
+
inputs=[duration, preset],
|
| 87 |
+
outputs=[output_audio, output_info]
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
return demo
|