ginipick commited on
Commit
a6582cc
Β·
verified Β·
1 Parent(s): 8c01fb9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -18
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": gr.utils.get_datetime()
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
- # submit_btn.click 이벀트 ν•Έλ“€λŸ¬λ„ μˆ˜μ •
662
- submit_btn.click(
663
- fn=generate_with_progress,
664
- inputs=[genre_txt, lyrics_txt, num_segments, max_new_tokens, history_state],
665
- outputs=[music_out, history_state, history_container, progress]
 
 
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__":