ginipick commited on
Commit
b29f642
Β·
verified Β·
1 Parent(s): d9ef286

Update ui/components-backup2.py

Browse files
Files changed (1) hide show
  1. 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
- prompt = enhance_prompt_with_genre(prompt, genre_preset)
 
 
 
226
 
227
  # μΊμ‹œ 확인
228
  cache_params = {
229
- 'prompt': prompt, 'lyrics': lyrics, 'audio_duration': audio_duration,
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, prompt, lyrics, infer_step, guidance_scale,
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
- candidates = []
253
-
254
- for i in range(num_candidates):
255
- seed = random.randint(1, 10000)
256
-
257
- try:
258
- result = original_func(
259
- audio_duration, prompt, lyrics, infer_step, guidance_scale,
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
- print(args)
329
- return []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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. **ν’ˆμ§ˆ μ„€μ •**: Draft(빠름) β†’ Standard(ꢌμž₯) β†’ High Quality β†’ Ultra 쀑 선택
1322
- 3. **닀쀑 생성**: "Best of 3/5/10" μ„ νƒν•˜λ©΄ μ—¬λŸ¬ 번 μƒμ„±ν•˜μ—¬ 졜고 ν’ˆμ§ˆμ„ μžλ™ μ„ νƒν•©λ‹ˆλ‹€
1323
- 4. **프리뷰**: 전체 생성 μ „ 10초 ν”„λ¦¬λ·°λ‘œ λΉ λ₯΄κ²Œ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€
 
 
 
 
 
 
 
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",