haepada commited on
Commit
a5eed8c
·
verified ·
1 Parent(s): 07cd318

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -50
app.py CHANGED
@@ -708,36 +708,21 @@ def create_interface():
708
  return (
709
  state,
710
  "음성을 먼저 녹음해주세요.",
711
- gr.update(visible=False), # loading
712
- gr.update(visible=False), # voice_features
713
- gr.update(visible=False), # text_sentiment
714
- gr.update(visible=False), # analysis_result
715
- gr.update(visible=True), # blessing_section
716
- gr.update(visible=False) # entry_guide_section
717
  )
718
 
719
  try:
720
- # 분석 시작 표시
721
- yield (
722
- state,
723
- "🔄 기준 음성을 분석중입니다... (약 10초 소요)",
724
- gr.update(value='''
725
- <div style="display:flex;justify-content:center;align-items:center;height:50px;overflow:hidden;">
726
- <div class="loader" style="width:30px;height:30px;"></div>
727
- </div>
728
- ''', visible=True),
729
- gr.update(visible=False),
730
- gr.update(visible=False),
731
- gr.update(visible=False),
732
- gr.update(visible=True),
733
- gr.update(visible=False)
734
- )
735
-
736
  features = calculate_baseline_features(audio)
737
  if features is None:
738
  return (
739
  state,
740
- "❌ 음성 분석에 실패했습니다.",
741
  gr.update(visible=False),
742
  gr.update(visible=False),
743
  gr.update(visible=False),
@@ -746,21 +731,10 @@ def create_interface():
746
  gr.update(visible=False)
747
  )
748
 
749
- # 감정 분석 중 표시
750
- yield (
751
- state,
752
- "🔄 음성의 감정과 특성을 분석중입니다... (약 5초 소요)",
753
- gr.update(visible=True),
754
- gr.update(visible=False),
755
- gr.update(visible=False),
756
- gr.update(visible=False),
757
- gr.update(visible=True),
758
- gr.update(visible=False)
759
- )
760
-
761
  baseline_emotion = map_acoustic_to_emotion(features)
762
 
763
- # 분석 결과 생성 - 음성 특성만 분석
764
  voice_features_text = f"""
765
  🎭 음성 특성 분석:
766
 
@@ -780,31 +754,30 @@ def create_interface():
780
 
781
  analysis_text = """
782
  ✨ 기준 음성 분석이 완료되었습니다.
783
-
784
- 이 음성 특성을 기준으로 이후의 감정 변화를 분석합니다.
785
  청신 단계에서 마음을 정화하신 후 기원을 진행해주세요.
786
  """
787
 
788
- # 상태 업데이트
789
  new_state = safe_state_update(state, {
790
  "baseline_features": features,
791
  "baseline_emotion": baseline_emotion,
792
  "analysis_complete": True
793
  })
794
 
795
- # 최종 결과 반환
796
  return (
797
  new_state,
798
- "✅ 축원이 완료되었습니다. 이제 청신 단계로 진행해주세요.",
799
- gr.update(visible=False),
800
- gr.update(value=voice_features_text, visible=True),
801
- gr.update(value=sentiment_text, visible=True),
802
- gr.update(value=analysis_text, visible=True),
803
- gr.update(visible=False),
804
- gr.update(visible=True)
805
  )
806
 
807
  except Exception as e:
 
808
  return (
809
  state,
810
  f"❌ 오류가 발생했습니다: {str(e)}",
@@ -1082,10 +1055,8 @@ def create_interface():
1082
  analysis_result, # 최종 분석 결과
1083
  blessing_section, # 축원 섹션
1084
  entry_guide_section # 가이드 섹션
1085
- ],
1086
- api_name="analyze_blessing" # API 이름 추가
1087
  )
1088
-
1089
  enter_btn.click(
1090
  fn=handle_enter,
1091
  outputs=[tabs]
 
708
  return (
709
  state,
710
  "음성을 먼저 녹음해주세요.",
711
+ gr.update(visible=False),
712
+ gr.update(visible=False),
713
+ gr.update(visible=False),
714
+ gr.update(visible=False),
715
+ gr.update(visible=True),
716
+ gr.update(visible=False)
717
  )
718
 
719
  try:
720
+ # 1. 음성 특성 분석
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
721
  features = calculate_baseline_features(audio)
722
  if features is None:
723
  return (
724
  state,
725
+ "❌ 음성 분석에 실패했습니다. 다시 시도해주세요.",
726
  gr.update(visible=False),
727
  gr.update(visible=False),
728
  gr.update(visible=False),
 
731
  gr.update(visible=False)
732
  )
733
 
734
+ # 2. 감정 분석
 
 
 
 
 
 
 
 
 
 
 
735
  baseline_emotion = map_acoustic_to_emotion(features)
736
 
737
+ # 3. 분석 결과 생성
738
  voice_features_text = f"""
739
  🎭 음성 특성 분석:
740
 
 
754
 
755
  analysis_text = """
756
  ✨ 기준 음성 분석이 완료되었습니다.
 
 
757
  청신 단계에서 마음을 정화하신 후 기원을 진행해주세요.
758
  """
759
 
760
+ # 4. 상태 업데이트
761
  new_state = safe_state_update(state, {
762
  "baseline_features": features,
763
  "baseline_emotion": baseline_emotion,
764
  "analysis_complete": True
765
  })
766
 
767
+ # 5. 최종 결과 반환 - 여기서 entry_guide_section을 보이게 설정
768
  return (
769
  new_state,
770
+ "✅ 축원이 완료되었습니다.",
771
+ gr.update(visible=False), # loading_icon
772
+ gr.update(value=voice_features_text, visible=True), # voice_features
773
+ gr.update(value=sentiment_text, visible=True), # text_sentiment
774
+ gr.update(value=analysis_text, visible=True), # analysis_result
775
+ gr.update(visible=False), # blessing_section
776
+ gr.update(visible=True) # entry_guide_section - 중요: 다음 단계로 진행
777
  )
778
 
779
  except Exception as e:
780
+ print(f"Error in handle_blessing_complete: {str(e)}")
781
  return (
782
  state,
783
  f"❌ 오류가 발생했습니다: {str(e)}",
 
1055
  analysis_result, # 최종 분석 결과
1056
  blessing_section, # 축원 섹션
1057
  entry_guide_section # 가이드 섹션
1058
+ ]
 
1059
  )
 
1060
  enter_btn.click(
1061
  fn=handle_enter,
1062
  outputs=[tabs]