haepada commited on
Commit
d753761
·
verified ·
1 Parent(s): e908d03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -701,12 +701,12 @@ def create_interface():
701
  f"- 감정: {baseline_emotion['primary']}\n"
702
  f"- 에너지 레벨: {baseline_emotion['details']['energy_level']}\n"
703
  f"- 말하기 속도: {baseline_emotion['details']['speech_rate']}\n"
704
- f"- 음높이: {baseline_emotion['details']['pitch_variation']}\n"
705
  f"이 음성을 기준으로 이후 소원을 비교 분석합니다."
706
  )
707
 
708
  # 상태 업데이트
709
- new_state = {**state, "baseline_features": features, "analysis_complete": True}
710
 
711
  return (
712
  new_state, # state
@@ -724,7 +724,8 @@ def create_interface():
724
  gr.update(visible=True),
725
  gr.update(visible=False)
726
  )
727
-
 
728
  # 4단계: 굿판 입장 안내
729
  entry_guide_section = gr.Column(visible=False)
730
  with entry_guide_section:
@@ -774,7 +775,6 @@ def create_interface():
774
  row_count=(5, "dynamic") # 동적으로 행 수 조정
775
  )
776
 
777
-
778
  # 기원 탭
779
  with gr.TabItem("기원") as tab_wish:
780
  gr.Markdown("## 기원 - 소원을 전해보세요")
@@ -964,10 +964,9 @@ def create_interface():
964
  print(f"Error saving reflection: {e}")
965
  return state, []
966
 
967
-
968
  def handle_save_wish(text, state):
969
  if not text.strip():
970
- return "소원을 입력해주세요.", []
971
 
972
  try:
973
  name = state.get("user_name", "익명")
@@ -977,10 +976,11 @@ def create_interface():
977
  [wish["timestamp"], wish["wish"], wish["name"]]
978
  for wish in wishes
979
  ]
980
- return "소원이 저장되었습니다.", wish_display_data
981
  except Exception as e:
982
  print(f"Error saving wish: {e}")
983
- return "오류가 발생했습니다.", []
 
984
 
985
  # 이벤트 연결
986
  name_submit_btn.click(
@@ -993,7 +993,8 @@ def create_interface():
993
  fn=handle_continue,
994
  outputs=[story_section, welcome_section, blessing_section, entry_guide_section]
995
  )
996
-
 
997
  set_baseline_btn.click(
998
  fn=handle_blessing_complete,
999
  inputs=[baseline_audio, state],
@@ -1042,8 +1043,9 @@ def create_interface():
1042
  save_final_btn.click(
1043
  fn=handle_save_wish,
1044
  inputs=[final_reflection, state],
1045
- outputs=[gr.Markdown(""), wishes_display] # baseline_status 대신 빈 Markdown 사용
1046
  )
 
1047
  return app
1048
 
1049
  if __name__ == "__main__":
 
701
  f"- 감정: {baseline_emotion['primary']}\n"
702
  f"- 에너지 레벨: {baseline_emotion['details']['energy_level']}\n"
703
  f"- 말하기 속도: {baseline_emotion['details']['speech_rate']}\n"
704
+ f"- 음높이 변화: {baseline_emotion['details']['pitch_variation']}\n"
705
  f"이 음성을 기준으로 이후 소원을 비교 분석합니다."
706
  )
707
 
708
  # 상태 업데이트
709
+ new_state = safe_state_update(state, {"baseline_features": features, "analysis_complete": True})
710
 
711
  return (
712
  new_state, # state
 
724
  gr.update(visible=True),
725
  gr.update(visible=False)
726
  )
727
+
728
+
729
  # 4단계: 굿판 입장 안내
730
  entry_guide_section = gr.Column(visible=False)
731
  with entry_guide_section:
 
775
  row_count=(5, "dynamic") # 동적으로 행 수 조정
776
  )
777
 
 
778
  # 기원 탭
779
  with gr.TabItem("기원") as tab_wish:
780
  gr.Markdown("## 기원 - 소원을 전해보세요")
 
964
  print(f"Error saving reflection: {e}")
965
  return state, []
966
 
 
967
  def handle_save_wish(text, state):
968
  if not text.strip():
969
+ return state, "소원을 입력해주세요.", []
970
 
971
  try:
972
  name = state.get("user_name", "익명")
 
976
  [wish["timestamp"], wish["wish"], wish["name"]]
977
  for wish in wishes
978
  ]
979
+ return state, "소원이 저장되었습니다.", wish_display_data
980
  except Exception as e:
981
  print(f"Error saving wish: {e}")
982
+ return state, "오류가 발생했습니다.", []
983
+
984
 
985
  # 이벤트 연결
986
  name_submit_btn.click(
 
993
  fn=handle_continue,
994
  outputs=[story_section, welcome_section, blessing_section, entry_guide_section]
995
  )
996
+
997
+ # 이벤트 연결부터 수정
998
  set_baseline_btn.click(
999
  fn=handle_blessing_complete,
1000
  inputs=[baseline_audio, state],
 
1043
  save_final_btn.click(
1044
  fn=handle_save_wish,
1045
  inputs=[final_reflection, state],
1046
+ outputs=[state, baseline_status, wishes_display]
1047
  )
1048
+
1049
  return app
1050
 
1051
  if __name__ == "__main__":