ginipick commited on
Commit
d9c83e6
Β·
verified Β·
1 Parent(s): edfc27d

Update app-backup.py

Browse files
Files changed (1) hide show
  1. app-backup.py +53 -18
app-backup.py CHANGED
@@ -20,12 +20,9 @@ logging.basicConfig(
20
  ]
21
  )
22
 
23
- # 가사 뢄석 ν•¨μˆ˜
24
- def analyze_lyrics(lyrics):
25
- # 쀄 λ‹¨μœ„λ‘œ 뢄리
26
  lines = [line.strip() for line in lyrics.split('\n') if line.strip()]
27
 
28
- # μ„Ήμ…˜ 카운트
29
  sections = {
30
  'verse': 0,
31
  'chorus': 0,
@@ -35,29 +32,46 @@ def analyze_lyrics(lyrics):
35
 
36
  current_section = None
37
  section_lines = {
38
- 'verse': 0,
39
- 'chorus': 0,
40
- 'bridge': 0
41
  }
42
-
43
  for line in lines:
44
  lower_line = line.lower()
45
  if '[verse]' in lower_line:
46
  current_section = 'verse'
47
  sections['verse'] += 1
 
48
  elif '[chorus]' in lower_line:
49
  current_section = 'chorus'
50
  sections['chorus'] += 1
 
51
  elif '[bridge]' in lower_line:
52
  current_section = 'bridge'
53
  sections['bridge'] += 1
54
- elif current_section and line.strip():
55
- section_lines[current_section] += 1
56
-
57
- # 총 μ„Ήμ…˜ 수 계산
58
- total_sections = sections['verse'] + sections['chorus'] + sections['bridge']
 
 
 
 
 
 
 
 
 
 
59
 
60
- return sections, total_sections, len(lines), section_lines
 
 
 
 
 
61
 
62
  def calculate_generation_params(lyrics):
63
  sections, total_sections, total_lines, section_lines = analyze_lyrics(lyrics)
@@ -460,6 +474,18 @@ Whispers of the night wind echo through the hall
460
  Lost within the silence, I hear your gentle voice
461
  Guiding me back homeward, making my heart rejoice
462
 
 
 
 
 
 
 
 
 
 
 
 
 
463
  [chorus]
464
  Don't let this moment fade, hold me close tonight
465
  With you here beside me, everything's alright
@@ -471,12 +497,21 @@ Stay with me forever, let our love just flow
471
  [
472
  "K-pop bright energetic synth dance electronic",
473
  """[verse]
474
- λΉ›λ‚˜λŠ” λ³„λ“€μ²˜λŸΌ 우리의 꿈이
475
- μ € ν•˜λŠ˜μ„ μˆ˜λ†“μ•„ λ°˜μ§μ΄λ„€
476
- ν•¨κ»˜λΌλ©΄ μ–΄λ””λ“  갈 수 μžˆμ–΄
477
 
478
  [chorus]
479
- λ‹¬λ €κ°€μž 더 높이 더 멀리
 
 
 
 
 
 
 
 
 
 
480
 
481
  """
482
  ]
 
20
  ]
21
  )
22
 
23
+ def analyze_lyrics(lyrics, repeat_chorus=2):
 
 
24
  lines = [line.strip() for line in lyrics.split('\n') if line.strip()]
25
 
 
26
  sections = {
27
  'verse': 0,
28
  'chorus': 0,
 
32
 
33
  current_section = None
34
  section_lines = {
35
+ 'verse': [],
36
+ 'chorus': [],
37
+ 'bridge': []
38
  }
39
+
40
  for line in lines:
41
  lower_line = line.lower()
42
  if '[verse]' in lower_line:
43
  current_section = 'verse'
44
  sections['verse'] += 1
45
+ continue
46
  elif '[chorus]' in lower_line:
47
  current_section = 'chorus'
48
  sections['chorus'] += 1
49
+ continue
50
  elif '[bridge]' in lower_line:
51
  current_section = 'bridge'
52
  sections['bridge'] += 1
53
+ continue
54
+
55
+ # ν˜„μž¬ μ„Ήμ…˜μ— 라인 μΆ”κ°€
56
+ if current_section:
57
+ section_lines[current_section].append(line)
58
+
59
+ # λ§Œμ•½ μ½”λŸ¬μŠ€κ°€ 1회만 있고, repeat_chorus > 1이면 λ°˜λ³΅ν•΄μ„œ 뢙이기
60
+ # chorus μ„Ήμ…˜ 전체 블둝을 볡제
61
+ if sections['chorus'] == 1 and repeat_chorus > 1:
62
+ chorus_block = section_lines['chorus'][:]
63
+ for _ in range(repeat_chorus - 1):
64
+ section_lines['chorus'].extend(chorus_block)
65
+
66
+ # 라인 수 μž¬κ³„μ‚°
67
+ new_total_lines = sum(len(section_lines[sec]) for sec in section_lines)
68
 
69
+ return sections, (sections['verse'] + sections['chorus'] + sections['bridge']), new_total_lines, {
70
+ 'verse': len(section_lines['verse']),
71
+ 'chorus': len(section_lines['chorus']),
72
+ 'bridge': len(section_lines['bridge'])
73
+ }
74
+
75
 
76
  def calculate_generation_params(lyrics):
77
  sections, total_sections, total_lines, section_lines = analyze_lyrics(lyrics)
 
474
  Lost within the silence, I hear your gentle voice
475
  Guiding me back homeward, making my heart rejoice
476
 
477
+ [chorus]
478
+ Don't let this moment fade, hold me close tonight
479
+ With you here beside me, everything's alright
480
+ Can't imagine life alone, don't want to let you go
481
+ Stay with me forever, let our love just flow
482
+
483
+ [verse]
484
+ In the quiet of the evening, shadows start to fall
485
+ Whispers of the night wind echo through the hall
486
+ Lost within the silence, I hear your gentle voice
487
+ Guiding me back homeward, making my heart rejoice
488
+
489
  [chorus]
490
  Don't let this moment fade, hold me close tonight
491
  With you here beside me, everything's alright
 
497
  [
498
  "K-pop bright energetic synth dance electronic",
499
  """[verse]
500
+ μ–Έμ  κ°€ λ§ˆμ£Όν•œ λˆˆλΉ› μ†μ—μ„œ
501
+ 우린 μ„œλ‘œλ₯Ό μ•Œμ•„λ³΄μ•˜μ§€
 
502
 
503
  [chorus]
504
+ λ‹€μ‹œ ν•œ 번 λ‚΄κ²Œ λ§ν•΄μ€˜
505
+ λ„ˆμ˜ 진심을 μˆ¨κΈ°μ§€ 말아 쀘
506
+
507
+ [verse]
508
+ μ–΄λ‘μš΄ 밀을 지날 λ•Œλ§ˆλ‹€
509
+ λ„ˆμ˜ λͺ©μ†Œλ¦¬λ₯Ό λ– μ˜¬λ €
510
+
511
+ [chorus]
512
+ λ‹€μ‹œ ν•œ 번 λ‚΄κ²Œ λ§ν•΄μ€˜
513
+ λ„ˆμ˜ 진심을 μˆ¨κΈ°μ§€ 말아 쀘
514
+
515
 
516
  """
517
  ]