Spaces:
Building
on
L40S
Building
on
L40S
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,8 @@ import re
|
|
10 |
from concurrent.futures import ThreadPoolExecutor
|
11 |
from functools import lru_cache
|
12 |
|
|
|
|
|
13 |
# λ‘κΉ
μ€μ
|
14 |
logging.basicConfig(
|
15 |
level=logging.INFO,
|
@@ -608,16 +610,18 @@ Don't let this moment fade, hold me close tonight
|
|
608 |
f"π Verses: {sections['verse']}, Chorus: {sections['chorus']}"
|
609 |
)
|
610 |
|
|
|
|
|
611 |
def update_history(audio_path, genre, lyrics, history):
|
612 |
if audio_path:
|
613 |
new_entry = {
|
614 |
"audio": audio_path,
|
615 |
"genre": genre,
|
616 |
"lyrics": lyrics,
|
617 |
-
"timestamp":
|
618 |
}
|
619 |
history = [new_entry] + (history or [])
|
620 |
-
|
621 |
history_html = "<div class='history-entries'>"
|
622 |
for entry in history:
|
623 |
history_html += f"""
|
@@ -629,24 +633,15 @@ Don't let this moment fade, hold me close tonight
|
|
629 |
</div>
|
630 |
"""
|
631 |
history_html += "</div>"
|
632 |
-
|
633 |
return history, history_html
|
634 |
return history, ""
|
635 |
|
636 |
-
# μ΄λ²€νΈ νΈλ€λ¬
|
637 |
-
lyrics_txt.change(
|
638 |
-
fn=update_info,
|
639 |
-
inputs=[lyrics_txt],
|
640 |
-
outputs=[duration_info, sections_info]
|
641 |
-
)
|
642 |
-
|
643 |
-
|
644 |
def generate_with_progress(genre, lyrics, segments, tokens, history):
|
645 |
try:
|
646 |
-
# μ§ν μνλ₯Ό λ°νκ°μ ν¬ν¨
|
647 |
status_text = "π΅ Starting generation..."
|
648 |
result = infer(genre, lyrics, segments, tokens)
|
649 |
-
|
650 |
if result:
|
651 |
status_text = "β
Generation complete!"
|
652 |
new_history, history_html = update_history(result, genre, lyrics, history)
|
@@ -658,15 +653,18 @@ Don't let this moment fade, hold me close tonight
|
|
658 |
status_text = f"β Error: {str(e)}"
|
659 |
return None, history, "", status_text
|
660 |
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
|
|
|
|
666 |
)
|
667 |
|
668 |
|
669 |
|
|
|
670 |
return demo
|
671 |
|
672 |
if __name__ == "__main__":
|
|
|
10 |
from concurrent.futures import ThreadPoolExecutor
|
11 |
from functools import lru_cache
|
12 |
|
13 |
+
from datetime import datetime
|
14 |
+
|
15 |
# λ‘κΉ
μ€μ
|
16 |
logging.basicConfig(
|
17 |
level=logging.INFO,
|
|
|
610 |
f"π Verses: {sections['verse']}, Chorus: {sections['chorus']}"
|
611 |
)
|
612 |
|
613 |
+
|
614 |
+
|
615 |
def update_history(audio_path, genre, lyrics, history):
|
616 |
if audio_path:
|
617 |
new_entry = {
|
618 |
"audio": audio_path,
|
619 |
"genre": genre,
|
620 |
"lyrics": lyrics,
|
621 |
+
"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S") # datetime μ§μ μ¬μ©
|
622 |
}
|
623 |
history = [new_entry] + (history or [])
|
624 |
+
|
625 |
history_html = "<div class='history-entries'>"
|
626 |
for entry in history:
|
627 |
history_html += f"""
|
|
|
633 |
</div>
|
634 |
"""
|
635 |
history_html += "</div>"
|
636 |
+
|
637 |
return history, history_html
|
638 |
return history, ""
|
639 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
640 |
def generate_with_progress(genre, lyrics, segments, tokens, history):
|
641 |
try:
|
|
|
642 |
status_text = "π΅ Starting generation..."
|
643 |
result = infer(genre, lyrics, segments, tokens)
|
644 |
+
|
645 |
if result:
|
646 |
status_text = "β
Generation complete!"
|
647 |
new_history, history_html = update_history(result, genre, lyrics, history)
|
|
|
653 |
status_text = f"β Error: {str(e)}"
|
654 |
return None, history, "", status_text
|
655 |
|
656 |
+
|
657 |
+
|
658 |
+
# μ΄λ²€νΈ νΈλ€λ¬
|
659 |
+
lyrics_txt.change(
|
660 |
+
fn=update_info,
|
661 |
+
inputs=[lyrics_txt],
|
662 |
+
outputs=[duration_info, sections_info]
|
663 |
)
|
664 |
|
665 |
|
666 |
|
667 |
+
|
668 |
return demo
|
669 |
|
670 |
if __name__ == "__main__":
|