Update app.py
Browse files
app.py
CHANGED
|
@@ -332,17 +332,30 @@ def generate_detailed_prompt(text, emotions, text_sentiment):
|
|
| 332 |
"차분/진지": "차분한 남색과 깊은 보라"
|
| 333 |
}
|
| 334 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
if emotions["intensity"] > 70:
|
| 336 |
-
visual_style = "역동적인 붓질과 강한
|
| 337 |
elif emotions["intensity"] > 40:
|
| 338 |
-
visual_style = "균형잡힌 구도와 중간 톤의
|
| 339 |
else:
|
| 340 |
-
visual_style = "부드러운 그라데이션과
|
| 341 |
|
| 342 |
-
prompt = f"
|
| 343 |
-
prompt += f"{visual_style}
|
| 344 |
-
prompt += f"
|
| 345 |
-
prompt +=
|
|
|
|
|
|
|
| 346 |
|
| 347 |
return prompt
|
| 348 |
|
|
@@ -687,8 +700,8 @@ def create_interface():
|
|
| 687 |
with gr.Column(visible=True) as analysis_section:
|
| 688 |
analysis_status = gr.Markdown("")
|
| 689 |
loading_icon = gr.HTML("""
|
| 690 |
-
<div
|
| 691 |
-
<
|
| 692 |
</div>
|
| 693 |
""")
|
| 694 |
voice_features = gr.Textbox(
|
|
@@ -718,6 +731,7 @@ def create_interface():
|
|
| 718 |
)
|
| 719 |
|
| 720 |
try:
|
|
|
|
| 721 |
features = calculate_baseline_features(audio)
|
| 722 |
if features is None:
|
| 723 |
return (
|
|
@@ -736,7 +750,6 @@ def create_interface():
|
|
| 736 |
|
| 737 |
voice_features_text = f"""
|
| 738 |
🎭 음성 특성 분석:
|
| 739 |
-
|
| 740 |
• 에너지 레벨: {baseline_emotion['details']['energy_level']}
|
| 741 |
• 말하기 속도: {baseline_emotion['details']['speech_rate']}
|
| 742 |
• 음높이 변화: {baseline_emotion['details']['pitch_variation']}
|
|
@@ -745,7 +758,6 @@ def create_interface():
|
|
| 745 |
|
| 746 |
sentiment_text = f"""
|
| 747 |
💫 기본 감정 상태:
|
| 748 |
-
|
| 749 |
• 주요 감정: {baseline_emotion['primary']}
|
| 750 |
• 감정 강도: {baseline_emotion['intensity']:.1f}%
|
| 751 |
• 특징: {', '.join(baseline_emotion['characteristics'])}
|
|
@@ -756,11 +768,12 @@ def create_interface():
|
|
| 756 |
결과를 확인하신 후 아래의 '다음 단계로' 버튼을 눌러주세요.
|
| 757 |
"""
|
| 758 |
|
| 759 |
-
new_state =
|
|
|
|
| 760 |
"baseline_features": features,
|
| 761 |
"baseline_emotion": baseline_emotion,
|
| 762 |
"analysis_complete": True
|
| 763 |
-
}
|
| 764 |
|
| 765 |
return (
|
| 766 |
new_state,
|
|
@@ -778,7 +791,7 @@ def create_interface():
|
|
| 778 |
print(f"Error in handle_blessing_complete: {str(e)}")
|
| 779 |
return (
|
| 780 |
state,
|
| 781 |
-
f"❌ 오류가
|
| 782 |
gr.update(visible=False),
|
| 783 |
gr.update(visible=False),
|
| 784 |
gr.update(visible=False),
|
|
@@ -787,51 +800,6 @@ def create_interface():
|
|
| 787 |
gr.update(visible=True),
|
| 788 |
gr.update(visible=False)
|
| 789 |
)
|
| 790 |
-
|
| 791 |
-
def next_section():
|
| 792 |
-
return (
|
| 793 |
-
gr.update(visible=False), # blessing_section
|
| 794 |
-
gr.update(visible=True) # entry_guide_section
|
| 795 |
-
)
|
| 796 |
-
|
| 797 |
-
# UI 구성
|
| 798 |
-
blessing_section = gr.Column(visible=False)
|
| 799 |
-
with blessing_section:
|
| 800 |
-
gr.Markdown("### 축원의식을 시작하겠습니다")
|
| 801 |
-
gr.Markdown("'명짐 복짐 짊어지고 안가태평하시기를 비도발원 축원 드립니다'")
|
| 802 |
-
|
| 803 |
-
with gr.Column() as recording_section:
|
| 804 |
-
baseline_audio = gr.Audio(
|
| 805 |
-
label="축원 문장 녹음하기",
|
| 806 |
-
sources=["microphone"],
|
| 807 |
-
type="numpy",
|
| 808 |
-
streaming=False
|
| 809 |
-
)
|
| 810 |
-
|
| 811 |
-
with gr.Column() as analysis_section:
|
| 812 |
-
set_baseline_btn = gr.Button("축원 마치기", variant="primary")
|
| 813 |
-
analysis_status = gr.Markdown("")
|
| 814 |
-
loading_icon = gr.HTML("""
|
| 815 |
-
<div style="display:flex;justify-content:center;align-items:center;height:50px;overflow:hidden;">
|
| 816 |
-
<div class="loader" style="width:30px;height:30px;"></div>
|
| 817 |
-
</div>
|
| 818 |
-
""")
|
| 819 |
-
voice_features = gr.Textbox(
|
| 820 |
-
label="음성 특성 분석",
|
| 821 |
-
interactive=False,
|
| 822 |
-
visible=False
|
| 823 |
-
)
|
| 824 |
-
text_sentiment = gr.Textbox(
|
| 825 |
-
label="기본 감정 상태",
|
| 826 |
-
interactive=False,
|
| 827 |
-
visible=False
|
| 828 |
-
)
|
| 829 |
-
analysis_result = gr.Markdown(visible=False)
|
| 830 |
-
next_button = gr.Button( # next_step_btn을 next_button으로 변경
|
| 831 |
-
"다음 단계로",
|
| 832 |
-
variant="primary",
|
| 833 |
-
visible=False
|
| 834 |
-
)
|
| 835 |
|
| 836 |
# 4단계: 굿판 입장 안내
|
| 837 |
entry_guide_section = gr.Column(visible=False)
|
|
|
|
| 332 |
"차분/진지": "차분한 남색과 깊은 보라"
|
| 333 |
}
|
| 334 |
|
| 335 |
+
abstract_elements = {
|
| 336 |
+
"기쁨/열정": "상승하는 나선형과 빛나는 입자들",
|
| 337 |
+
"분노/강조": "날카로운 지그재그와 폭발하는 형태",
|
| 338 |
+
"놀람/흥분": "물결치는 동심원과 반짝이는 점들",
|
| 339 |
+
"관심/호기심": "부드럽게 흐르는 곡선과 floating shapes",
|
| 340 |
+
"슬픔/우울": "하강하는 흐름과 흐릿한 그림자",
|
| 341 |
+
"피로/무기력": "느리게 흐르는 물결과 흐려지는 형태",
|
| 342 |
+
"평온/안정": "부드러운 원형과 조화로운 기하학적 패턴",
|
| 343 |
+
"차분/진지": "균형잡힌 수직선과 안정적인 구조"
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
if emotions["intensity"] > 70:
|
| 347 |
+
visual_style = "역동적인 붓질과 강한 대비의 추상적 구성"
|
| 348 |
elif emotions["intensity"] > 40:
|
| 349 |
+
visual_style = "균형잡힌 구도와 중간 톤의 기하학적 패턴"
|
| 350 |
else:
|
| 351 |
+
visual_style = "부드러운 그라데이션과 미니멀한 추상 형태"
|
| 352 |
|
| 353 |
+
prompt = f"abstract ethereal art, {emotion_colors.get(emotions['primary'], '자연스러운 색상')} 기반, "
|
| 354 |
+
prompt += f"{visual_style}, {abstract_elements.get(emotions['primary'], '유기적 형태')}. "
|
| 355 |
+
prompt += f"감정의 시각화: {emotions['characteristics'][0] if emotions['characteristics'] else '평온한 상태'}, "
|
| 356 |
+
prompt += "minimalistic composition, korean traditional art influence, no human figures, no faces. "
|
| 357 |
+
prompt += "geometric patterns, flowing energy, mystical atmosphere, ethereal lighting. "
|
| 358 |
+
prompt += "digital art, high detail, luminescent effects, --ar 2:3"
|
| 359 |
|
| 360 |
return prompt
|
| 361 |
|
|
|
|
| 700 |
with gr.Column(visible=True) as analysis_section:
|
| 701 |
analysis_status = gr.Markdown("")
|
| 702 |
loading_icon = gr.HTML("""
|
| 703 |
+
<div style="display:flex;justify-content:center;align-items:center;height:50px;overflow:hidden;">
|
| 704 |
+
<div class="loader" style="width:30px;height:30px;"></div>
|
| 705 |
</div>
|
| 706 |
""")
|
| 707 |
voice_features = gr.Textbox(
|
|
|
|
| 731 |
)
|
| 732 |
|
| 733 |
try:
|
| 734 |
+
# 간소화된 분석 과정
|
| 735 |
features = calculate_baseline_features(audio)
|
| 736 |
if features is None:
|
| 737 |
return (
|
|
|
|
| 750 |
|
| 751 |
voice_features_text = f"""
|
| 752 |
🎭 음성 특성 분석:
|
|
|
|
| 753 |
• 에너지 레벨: {baseline_emotion['details']['energy_level']}
|
| 754 |
• 말하기 속도: {baseline_emotion['details']['speech_rate']}
|
| 755 |
• 음높이 변화: {baseline_emotion['details']['pitch_variation']}
|
|
|
|
| 758 |
|
| 759 |
sentiment_text = f"""
|
| 760 |
💫 기본 감정 상태:
|
|
|
|
| 761 |
• 주요 감정: {baseline_emotion['primary']}
|
| 762 |
• 감정 강도: {baseline_emotion['intensity']:.1f}%
|
| 763 |
• 특징: {', '.join(baseline_emotion['characteristics'])}
|
|
|
|
| 768 |
결과를 확인하신 후 아래의 '다음 단계로' 버튼을 눌러주세요.
|
| 769 |
"""
|
| 770 |
|
| 771 |
+
new_state = {
|
| 772 |
+
**state,
|
| 773 |
"baseline_features": features,
|
| 774 |
"baseline_emotion": baseline_emotion,
|
| 775 |
"analysis_complete": True
|
| 776 |
+
}
|
| 777 |
|
| 778 |
return (
|
| 779 |
new_state,
|
|
|
|
| 791 |
print(f"Error in handle_blessing_complete: {str(e)}")
|
| 792 |
return (
|
| 793 |
state,
|
| 794 |
+
f"❌ 오류가 발생했습니다. 다시 시도해주세요.",
|
| 795 |
gr.update(visible=False),
|
| 796 |
gr.update(visible=False),
|
| 797 |
gr.update(visible=False),
|
|
|
|
| 800 |
gr.update(visible=True),
|
| 801 |
gr.update(visible=False)
|
| 802 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 803 |
|
| 804 |
# 4단계: 굿판 입장 안내
|
| 805 |
entry_guide_section = gr.Column(visible=False)
|