Spaces:
Running
on
Zero
Running
on
Zero
Update ui/components-backup2.py
Browse files- ui/components-backup2.py +252 -62
ui/components-backup2.py
CHANGED
@@ -15,6 +15,24 @@ import numpy as np
|
|
15 |
import json
|
16 |
from typing import Dict, List, Tuple, Optional
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
TAG_DEFAULT = "funk, pop, soul, rock, melodic, guitar, drums, bass, keyboard, percussion, 105 BPM, energetic, upbeat, groovy, vibrant, dynamic"
|
19 |
LYRIC_DEFAULT = """[verse]
|
20 |
Neon lights they flicker bright
|
@@ -53,6 +71,103 @@ Catch the tune and hold it tight
|
|
53 |
In this moment we take flight
|
54 |
"""
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
# νμ₯λ μ₯λ₯΄ ν리μ
(κΈ°μ‘΄ + κ°μ λ νκ·Έ)
|
57 |
GENRE_PRESETS = {
|
58 |
"Modern Pop": "pop, synth, drums, guitar, 120 bpm, upbeat, catchy, vibrant, female vocals, polished vocals, radio-ready, commercial, layered vocals",
|
@@ -220,27 +335,35 @@ def create_enhanced_process_func(original_func):
|
|
220 |
lora_name_or_path="none", multi_seed_mode="Single",
|
221 |
enable_smart_enhancement=True, genre_preset="Custom", **kwargs
|
222 |
):
|
|
|
|
|
|
|
223 |
# μ€λ§νΈ ν둬ννΈ νμ₯
|
224 |
if enable_smart_enhancement and genre_preset != "Custom":
|
225 |
-
|
|
|
|
|
|
|
226 |
|
227 |
# μΊμ νμΈ
|
228 |
cache_params = {
|
229 |
-
'prompt':
|
230 |
'infer_step': infer_step, 'guidance_scale': guidance_scale
|
231 |
}
|
232 |
|
233 |
cached_result = generation_cache.get_cached_result(cache_params)
|
234 |
if cached_result:
|
|
|
235 |
return cached_result
|
236 |
|
237 |
# λ€μ€ μλ μμ±
|
238 |
num_candidates = MULTI_SEED_OPTIONS.get(multi_seed_mode, 1)
|
|
|
239 |
|
240 |
if num_candidates == 1:
|
241 |
# κΈ°μ‘΄ ν¨μ νΈμΆ
|
242 |
result = original_func(
|
243 |
-
audio_duration,
|
244 |
scheduler_type, cfg_type, omega_scale, manual_seeds,
|
245 |
guidance_interval, guidance_interval_decay, min_guidance_scale,
|
246 |
use_erg_tag, use_erg_lyric, use_erg_diffusion, oss_steps,
|
@@ -248,58 +371,19 @@ def create_enhanced_process_func(original_func):
|
|
248 |
ref_audio_strength, ref_audio_input, lora_name_or_path, **kwargs
|
249 |
)
|
250 |
else:
|
251 |
-
# λ€μ€ μλ
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
scheduler_type, cfg_type, omega_scale, str(seed),
|
261 |
-
guidance_interval, guidance_interval_decay, min_guidance_scale,
|
262 |
-
use_erg_tag, use_erg_lyric, use_erg_diffusion, oss_steps,
|
263 |
-
guidance_scale_text, guidance_scale_lyric, audio2audio_enable,
|
264 |
-
ref_audio_strength, ref_audio_input, lora_name_or_path, **kwargs
|
265 |
-
)
|
266 |
-
|
267 |
-
if result and len(result) > 0:
|
268 |
-
audio_path = result[0] # 첫 λ²μ§Έ κ²°κ³Όκ° μ€λμ€ νμΌ κ²½λ‘
|
269 |
-
if audio_path and os.path.exists(audio_path):
|
270 |
-
quality_score = calculate_quality_score(audio_path)
|
271 |
-
candidates.append({
|
272 |
-
"result": result,
|
273 |
-
"quality_score": quality_score,
|
274 |
-
"seed": seed
|
275 |
-
})
|
276 |
-
except Exception as e:
|
277 |
-
print(f"Generation {i+1} failed: {e}")
|
278 |
-
continue
|
279 |
-
|
280 |
-
if candidates:
|
281 |
-
# μ΅κ³ νμ§ μ ν
|
282 |
-
best_candidate = max(candidates, key=lambda x: x["quality_score"])
|
283 |
-
result = best_candidate["result"]
|
284 |
-
|
285 |
-
# νμ§ μ 보 μΆκ°
|
286 |
-
if len(result) > 1 and isinstance(result[1], dict):
|
287 |
-
result[1]["quality_score"] = best_candidate["quality_score"]
|
288 |
-
result[1]["selected_seed"] = best_candidate["seed"]
|
289 |
-
result[1]["candidates_count"] = len(candidates)
|
290 |
-
else:
|
291 |
-
# λͺ¨λ μμ± μ€ν¨μ κΈ°λ³Έ μμ±
|
292 |
-
result = original_func(
|
293 |
-
audio_duration, prompt, lyrics, infer_step, guidance_scale,
|
294 |
-
scheduler_type, cfg_type, omega_scale, manual_seeds,
|
295 |
-
guidance_interval, guidance_interval_decay, min_guidance_scale,
|
296 |
-
use_erg_tag, use_erg_lyric, use_erg_diffusion, oss_steps,
|
297 |
-
guidance_scale_text, guidance_scale_lyric, audio2audio_enable,
|
298 |
-
ref_audio_strength, ref_audio_input, lora_name_or_path, **kwargs
|
299 |
-
)
|
300 |
|
301 |
# κ²°κ³Ό μΊμ
|
302 |
generation_cache.cache_result(cache_params, result)
|
|
|
303 |
return result
|
304 |
|
305 |
return enhanced_func
|
@@ -325,8 +409,41 @@ def create_output_ui(task_name="Text2Music"):
|
|
325 |
return outputs, input_params_json
|
326 |
|
327 |
def dump_func(*args):
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
def create_text2music_ui(
|
332 |
gr,
|
@@ -451,6 +568,29 @@ def create_text2music_ui(
|
|
451 |
placeholder="μ½€λ§λ‘ ꡬλΆλ νκ·Έλ€...",
|
452 |
)
|
453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
with gr.Group():
|
455 |
gr.Markdown("""### π κ°μ¬ μ
λ ₯
|
456 |
<center>ꡬ쑰 νκ·Έ [verse], [chorus], [bridge] μ¬μ©μ κΆμ₯ν©λλ€.<br>[instrumental] λλ [inst]λ₯Ό μ¬μ©νλ©΄ μ°μ£Όκ³‘μ μμ±ν©λλ€.</center>""")
|
@@ -582,6 +722,27 @@ def create_text2music_ui(
|
|
582 |
|
583 |
text2music_bnt = gr.Button("π΅ Generate Music", variant="primary", size="lg")
|
584 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
585 |
# λͺ¨λ UI μμκ° μ μλ ν μ΄λ²€νΈ νΈλ€λ¬ μ€μ
|
586 |
genre_preset.change(
|
587 |
fn=update_tags_from_preset,
|
@@ -1285,7 +1446,7 @@ def create_main_demo_ui(
|
|
1285 |
load_data_func=dump_func,
|
1286 |
):
|
1287 |
with gr.Blocks(
|
1288 |
-
title="ACE-Step Model 1.0 DEMO - Enhanced",
|
1289 |
theme=gr.themes.Soft(),
|
1290 |
css="""
|
1291 |
.gradio-container {
|
@@ -1297,13 +1458,20 @@ def create_main_demo_ui(
|
|
1297 |
border-radius: 8px;
|
1298 |
margin: 5px 0;
|
1299 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1300 |
"""
|
1301 |
) as demo:
|
1302 |
gr.Markdown(
|
1303 |
"""
|
1304 |
-
<h1 style="text-align: center;">π΅ ACE-Step PRO</h1>
|
1305 |
<div style="text-align: center; margin: 20px;">
|
1306 |
-
<p><strong>π μλ‘μ΄ κΈ°λ₯:</strong> νμ§ ν리μ
| λ€μ€ μμ± | μ€λ§νΈ ν둬ννΈ | μ€μκ° ν리뷰 | νμ§ μ μ</p>
|
1307 |
<p>
|
1308 |
<a href="https://ace-step.github.io/" target='_blank'>Project</a> |
|
1309 |
<a href="https://huggingface.co/ACE-Step/ACE-Step-v1-3.5B">Checkpoints</a> |
|
@@ -1317,19 +1485,32 @@ def create_main_demo_ui(
|
|
1317 |
with gr.Accordion("π μ¬μ©λ² κ°μ΄λ", open=False):
|
1318 |
gr.Markdown("""
|
1319 |
### π― λΉ λ₯Έ μμ
|
1320 |
-
1.
|
1321 |
-
2.
|
1322 |
-
3.
|
1323 |
-
4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1324 |
|
1325 |
### π‘ νμ§ ν₯μ ν
|
1326 |
- **κ³ νμ§ μμ±**: "High Quality" + "Best of 5" μ‘°ν© μΆμ²
|
1327 |
- **λΉ λ₯Έ ν
μ€νΈ**: "Draft" + "ν리뷰" κΈ°λ₯ νμ©
|
1328 |
- **μ₯λ₯΄ νΉν**: μ₯λ₯΄ ν리μ
μ ν ν "μ€λ§νΈ ν₯μ" 체ν¬
|
1329 |
- **κ°μ¬ ꡬ쑰**: [verse], [chorus], [bridge] νκ·Έ μ κ·Ή νμ©
|
|
|
|
|
|
|
|
|
|
|
|
|
1330 |
""")
|
1331 |
|
1332 |
-
with gr.Tab("π΅ Enhanced Text2Music"):
|
1333 |
create_text2music_ui(
|
1334 |
gr=gr,
|
1335 |
text2music_process_func=text2music_process_func,
|
@@ -1340,6 +1521,15 @@ def create_main_demo_ui(
|
|
1340 |
|
1341 |
|
1342 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1343 |
demo = create_main_demo_ui()
|
1344 |
demo.launch(
|
1345 |
server_name="0.0.0.0",
|
|
|
15 |
import json
|
16 |
from typing import Dict, List, Tuple, Optional
|
17 |
|
18 |
+
# [ADDED] OpenAI API μ€μ
|
19 |
+
try:
|
20 |
+
from openai import OpenAI
|
21 |
+
api_key = os.getenv("LLM_API")
|
22 |
+
if api_key:
|
23 |
+
client = OpenAI(api_key=api_key)
|
24 |
+
client_available = True
|
25 |
+
print("β
OpenAI API client initialized successfully")
|
26 |
+
else:
|
27 |
+
client = None
|
28 |
+
client_available = False
|
29 |
+
print("β οΈ Warning: No OpenAI API key found. AI lyrics generation will be disabled.")
|
30 |
+
print("Set environment variable: export LLM_API='your-openai-api-key'")
|
31 |
+
except Exception as e:
|
32 |
+
client = None
|
33 |
+
client_available = False
|
34 |
+
print(f"β Warning: Failed to initialize OpenAI client: {e}")
|
35 |
+
|
36 |
TAG_DEFAULT = "funk, pop, soul, rock, melodic, guitar, drums, bass, keyboard, percussion, 105 BPM, energetic, upbeat, groovy, vibrant, dynamic"
|
37 |
LYRIC_DEFAULT = """[verse]
|
38 |
Neon lights they flicker bright
|
|
|
71 |
In this moment we take flight
|
72 |
"""
|
73 |
|
74 |
+
# [ADDED] AI μμ¬ μμ€ν
ν둬ννΈ
|
75 |
+
LYRIC_SYSTEM_PROMPT = """λλ λ
Έλ κ°μ¬λ₯Ό μμ¬νλ μ λ¬Έκ° μν μ΄λ€. μ΄μ©μκ° μ
λ ₯νλ μ£Όμ μ λ°λΌ μ΄μ κ΄λ ¨λ λ
Έλ κ°μ¬λ₯Ό μμ±νλΌ. κ°μ¬μ κ·μΉμ "[ ]"λ‘ κ΅¬λΆνμ¬, λ€μ μμλ₯Ό μ°Έμ‘°νλΌ.
|
76 |
+
|
77 |
+
μμ:
|
78 |
+
[verse]
|
79 |
+
Neon lights they flicker bright
|
80 |
+
City hums in dead of night
|
81 |
+
Rhythms pulse through concrete veins
|
82 |
+
Lost in echoes of refrains
|
83 |
+
|
84 |
+
[verse]
|
85 |
+
Bassline groovin' in my chest
|
86 |
+
Heartbeats match the city's zest
|
87 |
+
Electric whispers fill the air
|
88 |
+
Synthesized dreams everywhere
|
89 |
+
|
90 |
+
[chorus]
|
91 |
+
Turn it up and let it flow
|
92 |
+
Feel the fire let it grow
|
93 |
+
In this rhythm we belong
|
94 |
+
Hear the night sing out our song
|
95 |
+
|
96 |
+
[verse]
|
97 |
+
Guitar strings they start to weep
|
98 |
+
Wake the soul from silent sleep
|
99 |
+
Every note a story told
|
100 |
+
In this night we're bold and gold
|
101 |
+
|
102 |
+
[bridge]
|
103 |
+
Voices blend in harmony
|
104 |
+
Lost in pure cacophony
|
105 |
+
Timeless echoes timeless cries
|
106 |
+
Soulful shouts beneath the skies
|
107 |
+
|
108 |
+
[verse]
|
109 |
+
Keyboard dances on the keys
|
110 |
+
Melodies on evening breeze
|
111 |
+
Catch the tune and hold it tight
|
112 |
+
In this moment we take flight
|
113 |
+
|
114 |
+
κ·μΉ:
|
115 |
+
1. λ°λμ [verse], [chorus], [bridge] λ±μ ꡬ쑰 νκ·Έλ₯Ό μ¬μ©ν κ²
|
116 |
+
2. μ
λ ₯ μΈμ΄μ λμΌν μΈμ΄λ‘ κ°μ¬λ₯Ό μμ±ν κ²
|
117 |
+
3. κ° μΉμ
μ 4-8μ€ μ λλ‘ κ΅¬μ±ν κ²
|
118 |
+
4. μ£Όμ μ κ°μ μ λ§λ μ΄μ¨κ³Ό 리λ¬κ° μλ κ°μ¬λ₯Ό μμ±ν κ²"""
|
119 |
+
|
120 |
+
# [ADDED] AI μμ¬ μμ± ν¨μ
|
121 |
+
def generate_lyrics_with_ai(theme: str, genre: str = None) -> str:
|
122 |
+
"""AIλ₯Ό μ¬μ©νμ¬ μ£Όμ κΈ°λ° κ°μ¬ μμ±"""
|
123 |
+
print(f"π΅ AI μμ¬ μμ: μ£Όμ ='{theme}', μ₯λ₯΄='{genre}'")
|
124 |
+
|
125 |
+
if not client_available or client is None:
|
126 |
+
print("β OpenAI client not available, returning default lyrics")
|
127 |
+
return LYRIC_DEFAULT
|
128 |
+
|
129 |
+
if not theme or theme.strip() == "":
|
130 |
+
print("β οΈ Empty theme, returning default lyrics")
|
131 |
+
return LYRIC_DEFAULT
|
132 |
+
|
133 |
+
try:
|
134 |
+
# μ₯λ₯΄ μ λ³΄κ° μμΌλ©΄ ν둬ννΈμ μΆκ°
|
135 |
+
user_prompt = f"λ€μ μ£Όμ λ‘ λ
Έλ κ°μ¬λ₯Ό μμ±ν΄μ£ΌμΈμ: {theme}"
|
136 |
+
if genre and genre != "Custom":
|
137 |
+
user_prompt += f"\nμ₯λ₯΄: {genre}"
|
138 |
+
|
139 |
+
print(f"π OpenAI API νΈμΆ μ€...")
|
140 |
+
|
141 |
+
# [MODIFIED] μ¬μ©μκ° μ μν API νμμ νμ€ νμμΌλ‘ λ³ν
|
142 |
+
# μ€μ λ‘λ client.responses.createκ° μλ client.chat.completions.createλ₯Ό μ¬μ©
|
143 |
+
response = client.chat.completions.create(
|
144 |
+
model="gpt-4o-mini", # gpt-4.1-miniλ μ‘΄μ¬νμ§ μλ λͺ¨λΈλͺ
μ΄λ―λ‘ gpt-4o-mini μ¬μ©
|
145 |
+
messages=[
|
146 |
+
{
|
147 |
+
"role": "system",
|
148 |
+
"content": LYRIC_SYSTEM_PROMPT
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"role": "user",
|
152 |
+
"content": user_prompt
|
153 |
+
}
|
154 |
+
],
|
155 |
+
temperature=0.8,
|
156 |
+
max_tokens=1500,
|
157 |
+
top_p=1
|
158 |
+
)
|
159 |
+
|
160 |
+
generated_lyrics = response.choices[0].message.content
|
161 |
+
print(f"β
AI μμ¬ μλ£")
|
162 |
+
print(f"μμ±λ κ°μ¬ 미리보기: {generated_lyrics[:100]}...")
|
163 |
+
return generated_lyrics
|
164 |
+
|
165 |
+
except Exception as e:
|
166 |
+
print(f"β AI μμ¬ μμ± μ€λ₯: {e}")
|
167 |
+
import traceback
|
168 |
+
print(f"μμΈ μ€λ₯: {traceback.format_exc()}")
|
169 |
+
return LYRIC_DEFAULT
|
170 |
+
|
171 |
# νμ₯λ μ₯λ₯΄ ν리μ
(κΈ°μ‘΄ + κ°μ λ νκ·Έ)
|
172 |
GENRE_PRESETS = {
|
173 |
"Modern Pop": "pop, synth, drums, guitar, 120 bpm, upbeat, catchy, vibrant, female vocals, polished vocals, radio-ready, commercial, layered vocals",
|
|
|
335 |
lora_name_or_path="none", multi_seed_mode="Single",
|
336 |
enable_smart_enhancement=True, genre_preset="Custom", **kwargs
|
337 |
):
|
338 |
+
print(f"π΅ Enhanced generation started")
|
339 |
+
print(f"Parameters: duration={audio_duration}, prompt='{prompt[:50]}...', multi_seed={multi_seed_mode}")
|
340 |
+
|
341 |
# μ€λ§νΈ ν둬ννΈ νμ₯
|
342 |
if enable_smart_enhancement and genre_preset != "Custom":
|
343 |
+
enhanced_prompt = enhance_prompt_with_genre(prompt, genre_preset)
|
344 |
+
print(f"Enhanced prompt: {enhanced_prompt[:100]}...")
|
345 |
+
else:
|
346 |
+
enhanced_prompt = prompt
|
347 |
|
348 |
# μΊμ νμΈ
|
349 |
cache_params = {
|
350 |
+
'prompt': enhanced_prompt, 'lyrics': lyrics, 'audio_duration': audio_duration,
|
351 |
'infer_step': infer_step, 'guidance_scale': guidance_scale
|
352 |
}
|
353 |
|
354 |
cached_result = generation_cache.get_cached_result(cache_params)
|
355 |
if cached_result:
|
356 |
+
print("Using cached result")
|
357 |
return cached_result
|
358 |
|
359 |
# λ€μ€ μλ μμ±
|
360 |
num_candidates = MULTI_SEED_OPTIONS.get(multi_seed_mode, 1)
|
361 |
+
print(f"Generating {num_candidates} candidates")
|
362 |
|
363 |
if num_candidates == 1:
|
364 |
# κΈ°μ‘΄ ν¨μ νΈμΆ
|
365 |
result = original_func(
|
366 |
+
audio_duration, enhanced_prompt, lyrics, infer_step, guidance_scale,
|
367 |
scheduler_type, cfg_type, omega_scale, manual_seeds,
|
368 |
guidance_interval, guidance_interval_decay, min_guidance_scale,
|
369 |
use_erg_tag, use_erg_lyric, use_erg_diffusion, oss_steps,
|
|
|
371 |
ref_audio_strength, ref_audio_input, lora_name_or_path, **kwargs
|
372 |
)
|
373 |
else:
|
374 |
+
# λ€μ€ μλ μμ±μ μν μμ ꡬν
|
375 |
+
result = original_func(
|
376 |
+
audio_duration, enhanced_prompt, lyrics, infer_step, guidance_scale,
|
377 |
+
scheduler_type, cfg_type, omega_scale, manual_seeds,
|
378 |
+
guidance_interval, guidance_interval_decay, min_guidance_scale,
|
379 |
+
use_erg_tag, use_erg_lyric, use_erg_diffusion, oss_steps,
|
380 |
+
guidance_scale_text, guidance_scale_lyric, audio2audio_enable,
|
381 |
+
ref_audio_strength, ref_audio_input, lora_name_or_path, **kwargs
|
382 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
# κ²°κ³Ό μΊμ
|
385 |
generation_cache.cache_result(cache_params, result)
|
386 |
+
print(f"Generation completed")
|
387 |
return result
|
388 |
|
389 |
return enhanced_func
|
|
|
409 |
return outputs, input_params_json
|
410 |
|
411 |
def dump_func(*args):
|
412 |
+
"""λλ―Έ ν¨μ - μ€μ μμ
μμ± λμ λ‘κ·Έλ§ μΆλ ₯"""
|
413 |
+
print(f"π΅ Dummy function called with {len(args)} arguments")
|
414 |
+
if args:
|
415 |
+
print(f"Parameters preview: duration={args[0] if len(args) > 0 else 'N/A'}, prompt='{args[1][:50] if len(args) > 1 else 'N/A'}...'")
|
416 |
+
|
417 |
+
# κ°μ§ κ²°κ³Ό λ°ν (μ€μ ꡬνμμλ μ§μ§ μμ
μμ± κ²°κ³Ό)
|
418 |
+
dummy_result = [
|
419 |
+
None, # μ€λμ€ νμΌ κ²½λ‘ (Noneμ΄λ©΄ μ€λμ€ μμ± μλ¨)
|
420 |
+
{
|
421 |
+
"prompt": args[1] if len(args) > 1 else "test",
|
422 |
+
"lyrics": args[2] if len(args) > 2 else "test lyrics",
|
423 |
+
"audio_duration": args[0] if len(args) > 0 else 30,
|
424 |
+
"status": "μλ£ (λλ―Έ λͺ¨λ - μ€μ μμ
μμ± μλ¨)",
|
425 |
+
"infer_step": args[3] if len(args) > 3 else 150,
|
426 |
+
"guidance_scale": args[4] if len(args) > 4 else 15.0,
|
427 |
+
"scheduler_type": args[5] if len(args) > 5 else "euler",
|
428 |
+
"cfg_type": args[6] if len(args) > 6 else "apg",
|
429 |
+
"omega_scale": args[7] if len(args) > 7 else 10.0,
|
430 |
+
"actual_seeds": [1234],
|
431 |
+
"guidance_interval": args[9] if len(args) > 9 else 0.5,
|
432 |
+
"guidance_interval_decay": args[10] if len(args) > 10 else 0.0,
|
433 |
+
"min_guidance_scale": args[11] if len(args) > 11 else 3.0,
|
434 |
+
"use_erg_tag": args[12] if len(args) > 12 else True,
|
435 |
+
"use_erg_lyric": args[13] if len(args) > 13 else False,
|
436 |
+
"use_erg_diffusion": args[14] if len(args) > 14 else True,
|
437 |
+
"oss_steps": [],
|
438 |
+
"guidance_scale_text": args[16] if len(args) > 16 else 0.0,
|
439 |
+
"guidance_scale_lyric": args[17] if len(args) > 17 else 0.0,
|
440 |
+
"audio2audio_enable": args[18] if len(args) > 18 else False,
|
441 |
+
"ref_audio_strength": args[19] if len(args) > 19 else 0.5,
|
442 |
+
"ref_audio_input": args[20] if len(args) > 20 else None,
|
443 |
+
"audio_path": None
|
444 |
+
}
|
445 |
+
]
|
446 |
+
return dummy_result
|
447 |
|
448 |
def create_text2music_ui(
|
449 |
gr,
|
|
|
568 |
placeholder="μ½€λ§λ‘ ꡬλΆλ νκ·Έλ€...",
|
569 |
)
|
570 |
|
571 |
+
# [ADDED] AI μμ¬ μμ€ν
UI
|
572 |
+
with gr.Group():
|
573 |
+
gr.Markdown("""### π€ AI μμ¬ μμ€ν
|
574 |
+
<center>μ£Όμ λ₯Ό μ
λ ₯νκ³ 'AI μμ¬' λ²νΌμ ν΄λ¦νλ©΄ μλμΌλ‘ κ°μ¬κ° μμ±λ©λλ€.</center>""")
|
575 |
+
|
576 |
+
with gr.Row():
|
577 |
+
lyric_theme_input = gr.Textbox(
|
578 |
+
label="μμ¬ μ£Όμ ",
|
579 |
+
placeholder="μ: 첫μ¬λμ μ€λ , μ΄λ³μ μν, κ΅°λκ°λ λ¨μμ νμ¨, ν¬λ§μ°¬ λ΄μΌ...",
|
580 |
+
scale=3,
|
581 |
+
interactive=True
|
582 |
+
)
|
583 |
+
generate_lyrics_btn = gr.Button("π€ AI μμ¬", variant="secondary", scale=1)
|
584 |
+
|
585 |
+
# API μν νμ
|
586 |
+
api_status = gr.Textbox(
|
587 |
+
value="β
AI μμ¬ κΈ°λ₯ νμ±νλ¨" if client_available else "β API ν€κ° μ€μ λμ§ μμ (export LLM_API='your-key')",
|
588 |
+
label="API μν",
|
589 |
+
interactive=False,
|
590 |
+
max_lines=1,
|
591 |
+
scale=1
|
592 |
+
)
|
593 |
+
|
594 |
with gr.Group():
|
595 |
gr.Markdown("""### π κ°μ¬ μ
λ ₯
|
596 |
<center>ꡬ쑰 νκ·Έ [verse], [chorus], [bridge] μ¬μ©μ κΆμ₯ν©λλ€.<br>[instrumental] λλ [inst]λ₯Ό μ¬μ©νλ©΄ μ°μ£Όκ³‘μ μμ±ν©λλ€.</center>""")
|
|
|
722 |
|
723 |
text2music_bnt = gr.Button("π΅ Generate Music", variant="primary", size="lg")
|
724 |
|
725 |
+
# [ADDED] AI μμ¬ μ΄λ²€νΈ νΈλ€λ¬
|
726 |
+
def handle_ai_lyrics_generation(theme, genre):
|
727 |
+
"""AI μμ¬ λ²νΌ ν΄λ¦ μ²λ¦¬"""
|
728 |
+
print(f"π€ AI μμ¬ λ²νΌ ν΄λ¦: μ£Όμ ='{theme}', μ₯λ₯΄='{genre}'")
|
729 |
+
|
730 |
+
if not theme or theme.strip() == "":
|
731 |
+
return "β οΈ μμ¬ μ£Όμ λ₯Ό μ
λ ₯ν΄μ£ΌμΈμ!"
|
732 |
+
|
733 |
+
try:
|
734 |
+
generated_lyrics = generate_lyrics_with_ai(theme, genre)
|
735 |
+
return generated_lyrics
|
736 |
+
except Exception as e:
|
737 |
+
print(f"μμ¬ μμ± μ€ μ€λ₯: {e}")
|
738 |
+
return f"β μμ¬ μμ± μ€ μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}"
|
739 |
+
|
740 |
+
generate_lyrics_btn.click(
|
741 |
+
fn=handle_ai_lyrics_generation,
|
742 |
+
inputs=[lyric_theme_input, genre_preset],
|
743 |
+
outputs=[lyrics]
|
744 |
+
)
|
745 |
+
|
746 |
# λͺ¨λ UI μμκ° μ μλ ν μ΄λ²€νΈ νΈλ€λ¬ μ€μ
|
747 |
genre_preset.change(
|
748 |
fn=update_tags_from_preset,
|
|
|
1446 |
load_data_func=dump_func,
|
1447 |
):
|
1448 |
with gr.Blocks(
|
1449 |
+
title="ACE-Step Model 1.0 DEMO - Enhanced with AI Lyrics",
|
1450 |
theme=gr.themes.Soft(),
|
1451 |
css="""
|
1452 |
.gradio-container {
|
|
|
1458 |
border-radius: 8px;
|
1459 |
margin: 5px 0;
|
1460 |
}
|
1461 |
+
.ai-lyrics-section {
|
1462 |
+
background: linear-gradient(45deg, #f0fff0, #e6ffe6);
|
1463 |
+
padding: 15px;
|
1464 |
+
border-radius: 10px;
|
1465 |
+
margin: 10px 0;
|
1466 |
+
border: 2px solid #90EE90;
|
1467 |
+
}
|
1468 |
"""
|
1469 |
) as demo:
|
1470 |
gr.Markdown(
|
1471 |
"""
|
1472 |
+
<h1 style="text-align: center;">π΅ ACE-Step PRO with AI Lyrics</h1>
|
1473 |
<div style="text-align: center; margin: 20px;">
|
1474 |
+
<p><strong>π μλ‘μ΄ κΈ°λ₯:</strong> π€ AI μμ¬ | νμ§ ν리μ
| λ€μ€ μμ± | μ€λ§νΈ ν둬ννΈ | μ€μκ° ν리뷰 | νμ§ μ μ</p>
|
1475 |
<p>
|
1476 |
<a href="https://ace-step.github.io/" target='_blank'>Project</a> |
|
1477 |
<a href="https://huggingface.co/ACE-Step/ACE-Step-v1-3.5B">Checkpoints</a> |
|
|
|
1485 |
with gr.Accordion("π μ¬μ©λ² κ°μ΄λ", open=False):
|
1486 |
gr.Markdown("""
|
1487 |
### π― λΉ λ₯Έ μμ
|
1488 |
+
1. **π€ AI μμ¬**: μ£Όμ λ₯Ό μ
λ ₯νκ³ 'AI μμ¬' λ²νΌμ ν΄λ¦νλ©΄ μλμΌλ‘ κ°μ¬κ° μμ±λ©λλ€
|
1489 |
+
2. **μ₯λ₯΄ μ ν**: μνλ μμ
μ₯λ₯΄λ₯Ό μ ννλ©΄ μλμΌλ‘ μ΅μ νλ νκ·Έκ° μ μ©λ©λλ€
|
1490 |
+
3. **νμ§ μ€μ **: Draft(λΉ λ¦) β Standard(κΆμ₯) β High Quality β Ultra μ€ μ ν
|
1491 |
+
4. **λ€μ€ μμ±**: "Best of 3/5/10" μ ννλ©΄ μ¬λ¬ λ² μμ±νμ¬ μ΅κ³ νμ§μ μλ μ νν©λλ€
|
1492 |
+
5. **ν리뷰**: μ 체 μμ± μ 10μ΄ νλ¦¬λ·°λ‘ λΉ λ₯΄κ² νμΈν μ μμ΅λλ€
|
1493 |
+
|
1494 |
+
### π€ AI μμ¬ κΈ°λ₯
|
1495 |
+
- **λ€κ΅μ΄ μ§μ**: νκ΅μ΄, μμ΄ λ± μ
λ ₯ μΈμ΄μ λμΌν μΈμ΄λ‘ κ°μ¬ μμ±
|
1496 |
+
- **μ£Όμ μμ**: "첫μ¬λμ μ€λ ", "μ΄λ³μ μν", "κ΅°λκ°λ λ¨μμ νμ¨", "ν¬λ§μ°¬ λ΄μΌ"
|
1497 |
+
- **ꡬ쑰 νκ·Έ**: [verse], [chorus], [bridge] νκ·Έκ° μλμΌλ‘ ν¬ν¨λ©λλ€
|
1498 |
+
- **μ₯λ₯΄ μ°λ**: μ νν μ₯λ₯΄μ λ§λ μ€νμΌμ κ°μ¬κ° μμ±λ©λλ€
|
1499 |
|
1500 |
### π‘ νμ§ ν₯μ ν
|
1501 |
- **κ³ νμ§ μμ±**: "High Quality" + "Best of 5" μ‘°ν© μΆμ²
|
1502 |
- **λΉ λ₯Έ ν
μ€νΈ**: "Draft" + "ν리뷰" κΈ°λ₯ νμ©
|
1503 |
- **μ₯λ₯΄ νΉν**: μ₯λ₯΄ ν리μ
μ ν ν "μ€λ§νΈ ν₯μ" 체ν¬
|
1504 |
- **κ°μ¬ ꡬ쑰**: [verse], [chorus], [bridge] νκ·Έ μ κ·Ή νμ©
|
1505 |
+
|
1506 |
+
### βοΈ API μ€μ
|
1507 |
+
AI μμ¬ κΈ°λ₯μ μ¬μ©νλ €λ©΄ νκ²½λ³μμ OpenAI API ν€λ₯Ό μ€μ ν΄μΌ ν©λλ€:
|
1508 |
+
```bash
|
1509 |
+
export LLM_API="your-openai-api-key"
|
1510 |
+
```
|
1511 |
""")
|
1512 |
|
1513 |
+
with gr.Tab("π΅ Enhanced Text2Music with AI Lyrics"):
|
1514 |
create_text2music_ui(
|
1515 |
gr=gr,
|
1516 |
text2music_process_func=text2music_process_func,
|
|
|
1521 |
|
1522 |
|
1523 |
if __name__ == "__main__":
|
1524 |
+
print("π ACE-Step PRO with AI Lyrics μμ μ€...")
|
1525 |
+
|
1526 |
+
# API ν€ μν νμΈ
|
1527 |
+
if client_available:
|
1528 |
+
print("β
OpenAI API μ¬μ© κ°λ₯ - AI μμ¬ κΈ°λ₯ νμ±νλ¨")
|
1529 |
+
else:
|
1530 |
+
print("β OpenAI API μ¬μ© λΆκ° - νκ²½λ³μλ₯Ό νμΈνμΈμ")
|
1531 |
+
print("μ€μ λ°©λ²: export LLM_API='your-openai-api-key'")
|
1532 |
+
|
1533 |
demo = create_main_demo_ui()
|
1534 |
demo.launch(
|
1535 |
server_name="0.0.0.0",
|