Update app.py
Browse files
app.py
CHANGED
@@ -339,7 +339,7 @@ def generate_detailed_prompt(text, emotions, text_sentiment):
|
|
339 |
else:
|
340 |
visual_style = "부드러운 그라데이션과 차분한 톤"
|
341 |
|
342 |
-
prompt = f"
|
343 |
prompt += f"{visual_style}로 표현된 {emotions['primary']}의 감정. "
|
344 |
prompt += f"음성의 특징({', '.join(emotions['characteristics'])})을 화면의 동적 요소로 표현. "
|
345 |
prompt += f"발화 내용 '{text}'에서 느껴지는 감정({text_sentiment['label']} - 점수: {text_sentiment['score']:.2f})을 은유적 이미지로 담아내기."
|
@@ -673,13 +673,24 @@ def create_interface():
|
|
673 |
def handle_blessing_complete(audio, state):
|
674 |
"""축원 완료 및 분석 처리"""
|
675 |
if audio is None:
|
676 |
-
return
|
677 |
-
|
|
|
|
|
|
|
|
|
|
|
678 |
try:
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
# 감정 분석
|
684 |
baseline_emotion = map_acoustic_to_emotion(features)
|
685 |
|
@@ -696,18 +707,24 @@ def create_interface():
|
|
696 |
# 상태 업데이트
|
697 |
new_state = {**state, "baseline_features": features, "analysis_complete": True}
|
698 |
|
699 |
-
# 분석이 완료되면 다음 단계로 진행
|
700 |
return (
|
701 |
-
new_state,
|
702 |
-
"축원이 완료되었습니다.",
|
703 |
-
analysis_text,
|
704 |
-
gr.update(visible=False),
|
705 |
-
gr.update(visible=True)
|
706 |
)
|
707 |
|
708 |
except Exception as e:
|
709 |
-
return
|
710 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
711 |
# 4단계: 굿판 입장 안내
|
712 |
entry_guide_section = gr.Column(visible=False)
|
713 |
with entry_guide_section:
|
@@ -981,11 +998,11 @@ def create_interface():
|
|
981 |
fn=handle_blessing_complete,
|
982 |
inputs=[baseline_audio, state],
|
983 |
outputs=[
|
984 |
-
state,
|
985 |
-
analysis_status,
|
986 |
-
analysis_result,
|
987 |
-
blessing_section,
|
988 |
-
entry_guide_section
|
989 |
]
|
990 |
)
|
991 |
|
|
|
339 |
else:
|
340 |
visual_style = "부드러운 그라데이션과 차분한 톤"
|
341 |
|
342 |
+
prompt = f"사이키델릭 민화, 네오민화 스타일의 추상화, {emotion_colors.get(emotions['primary'], '자연스러운 색상')} 기반. "
|
343 |
prompt += f"{visual_style}로 표현된 {emotions['primary']}의 감정. "
|
344 |
prompt += f"음성의 특징({', '.join(emotions['characteristics'])})을 화면의 동적 요소로 표현. "
|
345 |
prompt += f"발화 내용 '{text}'에서 느껴지는 감정({text_sentiment['label']} - 점수: {text_sentiment['score']:.2f})을 은유적 이미지로 담아내기."
|
|
|
673 |
def handle_blessing_complete(audio, state):
|
674 |
"""축원 완료 및 분석 처리"""
|
675 |
if audio is None:
|
676 |
+
return (
|
677 |
+
state,
|
678 |
+
"음성을 먼저 녹음해주세요.",
|
679 |
+
gr.update(visible=False), # analysis_result
|
680 |
+
gr.update(visible=True), # blessing_section
|
681 |
+
gr.update(visible=False), # entry_guide_section
|
682 |
+
)
|
683 |
try:
|
684 |
+
features = calculate_baseline_features(audio)
|
685 |
+
if features is None:
|
686 |
+
return (
|
687 |
+
state,
|
688 |
+
"음성 분석에 실패했습니다. 다시 시도해주세요.",
|
689 |
+
gr.update(visible=False),
|
690 |
+
gr.update(visible=True),
|
691 |
+
gr.update(visible=False)
|
692 |
+
)
|
693 |
+
|
694 |
# 감정 분석
|
695 |
baseline_emotion = map_acoustic_to_emotion(features)
|
696 |
|
|
|
707 |
# 상태 업데이트
|
708 |
new_state = {**state, "baseline_features": features, "analysis_complete": True}
|
709 |
|
710 |
+
# 분석이 완료되면 다음 단계로 진행 (모든 출력값 포함)
|
711 |
return (
|
712 |
+
new_state, # state
|
713 |
+
"축원이 완료되었습니다.", # status message
|
714 |
+
gr.update(value=analysis_text, visible=True), # analysis_result
|
715 |
+
gr.update(visible=False), # blessing_section
|
716 |
+
gr.update(visible=True) # entry_guide_section
|
717 |
)
|
718 |
|
719 |
except Exception as e:
|
720 |
+
return (
|
721 |
+
state,
|
722 |
+
f"오류가 발생했습니다: {str(e)}",
|
723 |
+
gr.update(visible=False),
|
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:
|
|
|
998 |
fn=handle_blessing_complete,
|
999 |
inputs=[baseline_audio, state],
|
1000 |
outputs=[
|
1001 |
+
state, # 상태
|
1002 |
+
analysis_status, # 상태 메시지
|
1003 |
+
analysis_result, # 분석 결과
|
1004 |
+
blessing_section, # 축원 섹션
|
1005 |
+
entry_guide_section # 가이드 섹션
|
1006 |
]
|
1007 |
)
|
1008 |
|