Update app-backup.py
Browse files- 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':
|
39 |
-
'chorus':
|
40 |
-
'bridge':
|
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 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
return sections,
|
|
|
|
|
|
|
|
|
|
|
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 |
]
|