File size: 3,135 Bytes
2c1e8f3
 
 
 
 
 
 
 
204ea61
 
2c1e8f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c3670f
 
2c1e8f3
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"""
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