Update app.py
Browse files
app.py
CHANGED
@@ -645,13 +645,13 @@ def create_interface():
|
|
645 |
interactive=True
|
646 |
)
|
647 |
name_submit_btn = gr.Button("굿판 시작하기", variant="primary")
|
648 |
-
|
649 |
# 2단계: 세계관 설명
|
650 |
story_section = gr.Column(visible=False)
|
651 |
with story_section:
|
652 |
gr.Markdown(ONCHEON_STORY)
|
653 |
continue_btn = gr.Button("준비하기", variant="primary")
|
654 |
-
|
655 |
# 3단계: 축원 의식
|
656 |
blessing_section = gr.Column(visible=False)
|
657 |
with blessing_section:
|
@@ -668,15 +668,15 @@ def create_interface():
|
|
668 |
"축원 문장을 녹음해주세요.",
|
669 |
visible=True
|
670 |
)
|
671 |
-
|
672 |
with gr.Column(visible=False) as analysis_results:
|
673 |
voice_analysis = gr.Markdown("")
|
674 |
set_baseline_btn = gr.Button(
|
675 |
-
"축원 마치기",
|
676 |
variant="primary",
|
677 |
visible=False
|
678 |
)
|
679 |
-
|
680 |
def handle_baseline_recording(audio, state):
|
681 |
"""기준 음성 분석"""
|
682 |
if audio is None:
|
@@ -687,7 +687,7 @@ def create_interface():
|
|
687 |
"button_visible": False,
|
688 |
"analysis_text": ""
|
689 |
}
|
690 |
-
|
691 |
try:
|
692 |
# 분석 중임을 표시
|
693 |
yield {
|
@@ -697,7 +697,7 @@ def create_interface():
|
|
697 |
"button_visible": False,
|
698 |
"analysis_text": ""
|
699 |
}
|
700 |
-
|
701 |
# 음성 분석
|
702 |
features = calculate_baseline_features(audio)
|
703 |
if features is None:
|
@@ -708,10 +708,10 @@ def create_interface():
|
|
708 |
"button_visible": False,
|
709 |
"analysis_text": ""
|
710 |
}
|
711 |
-
|
712 |
# 감정 분석
|
713 |
baseline_emotion = map_acoustic_to_emotion(features)
|
714 |
-
|
715 |
# 분석 결과 생성
|
716 |
analysis_text = (
|
717 |
f"기준 음성 분석 결과:\n"
|
@@ -721,10 +721,10 @@ def create_interface():
|
|
721 |
f"- 음높이: {baseline_emotion['details']['pitch_variation']}\n"
|
722 |
f"이 음성을 기준으로 이후 소원을 비교 분석합니다."
|
723 |
)
|
724 |
-
|
725 |
# 상태 업데이트
|
726 |
new_state = {**state, "baseline_features": features, "analysis_complete": True}
|
727 |
-
|
728 |
return {
|
729 |
"state": new_state,
|
730 |
"status": "",
|
@@ -732,7 +732,7 @@ def create_interface():
|
|
732 |
"button_visible": True,
|
733 |
"analysis_text": analysis_text
|
734 |
}
|
735 |
-
|
736 |
except Exception as e:
|
737 |
return {
|
738 |
"state": state,
|
@@ -741,58 +741,63 @@ def create_interface():
|
|
741 |
"button_visible": False,
|
742 |
"analysis_text": ""
|
743 |
}
|
744 |
-
|
745 |
def handle_blessing_complete(state):
|
746 |
"""축원 완료 처리"""
|
747 |
if not state.get("analysis_complete"):
|
748 |
return state, "음성 분석이 완료되지 않았습니다.", gr.update(visible=True), gr.update(visible=False)
|
749 |
-
|
750 |
return state, "", gr.update(visible=False), gr.update(visible=True)
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
|
|
|
|
|
|
|
|
|
|
796 |
|
797 |
# 기원 탭
|
798 |
with gr.TabItem("기원") as tab_wish:
|
|
|
645 |
interactive=True
|
646 |
)
|
647 |
name_submit_btn = gr.Button("굿판 시작하기", variant="primary")
|
648 |
+
|
649 |
# 2단계: 세계관 설명
|
650 |
story_section = gr.Column(visible=False)
|
651 |
with story_section:
|
652 |
gr.Markdown(ONCHEON_STORY)
|
653 |
continue_btn = gr.Button("준비하기", variant="primary")
|
654 |
+
|
655 |
# 3단계: 축원 의식
|
656 |
blessing_section = gr.Column(visible=False)
|
657 |
with blessing_section:
|
|
|
668 |
"축원 문장을 녹음해주세요.",
|
669 |
visible=True
|
670 |
)
|
671 |
+
|
672 |
with gr.Column(visible=False) as analysis_results:
|
673 |
voice_analysis = gr.Markdown("")
|
674 |
set_baseline_btn = gr.Button(
|
675 |
+
"축원 마치기",
|
676 |
variant="primary",
|
677 |
visible=False
|
678 |
)
|
679 |
+
|
680 |
def handle_baseline_recording(audio, state):
|
681 |
"""기준 음성 분석"""
|
682 |
if audio is None:
|
|
|
687 |
"button_visible": False,
|
688 |
"analysis_text": ""
|
689 |
}
|
690 |
+
|
691 |
try:
|
692 |
# 분석 중임을 표시
|
693 |
yield {
|
|
|
697 |
"button_visible": False,
|
698 |
"analysis_text": ""
|
699 |
}
|
700 |
+
|
701 |
# 음성 분석
|
702 |
features = calculate_baseline_features(audio)
|
703 |
if features is None:
|
|
|
708 |
"button_visible": False,
|
709 |
"analysis_text": ""
|
710 |
}
|
711 |
+
|
712 |
# 감정 분석
|
713 |
baseline_emotion = map_acoustic_to_emotion(features)
|
714 |
+
|
715 |
# 분석 결과 생성
|
716 |
analysis_text = (
|
717 |
f"기준 음성 분석 결과:\n"
|
|
|
721 |
f"- 음높이: {baseline_emotion['details']['pitch_variation']}\n"
|
722 |
f"이 음성을 기준으로 이후 소원을 비교 분석합니다."
|
723 |
)
|
724 |
+
|
725 |
# 상태 업데이트
|
726 |
new_state = {**state, "baseline_features": features, "analysis_complete": True}
|
727 |
+
|
728 |
return {
|
729 |
"state": new_state,
|
730 |
"status": "",
|
|
|
732 |
"button_visible": True,
|
733 |
"analysis_text": analysis_text
|
734 |
}
|
735 |
+
|
736 |
except Exception as e:
|
737 |
return {
|
738 |
"state": state,
|
|
|
741 |
"button_visible": False,
|
742 |
"analysis_text": ""
|
743 |
}
|
744 |
+
|
745 |
def handle_blessing_complete(state):
|
746 |
"""축원 완료 처리"""
|
747 |
if not state.get("analysis_complete"):
|
748 |
return state, "음성 분석이 완료되지 않았습니다.", gr.update(visible=True), gr.update(visible=False)
|
749 |
+
|
750 |
return state, "", gr.update(visible=False), gr.update(visible=True)
|
751 |
+
|
752 |
+
# 4단계: 굿판 입장 안내
|
753 |
+
entry_guide_section = gr.Column(visible=False)
|
754 |
+
with entry_guide_section:
|
755 |
+
gr.Markdown("## 굿판으로 입장하기")
|
756 |
+
gr.Markdown(
|
757 |
+
"""
|
758 |
+
* 청신 탭으로 이동해 주세요.
|
759 |
+
* 부산광역시 동래구 온천장역에서 시작하면 더욱 깊은 경험을 시작할 수 있습니다.
|
760 |
+
* (본격적인 경험을 시작하기에 앞서 이동을 권장드립니다)
|
761 |
+
"""
|
762 |
+
)
|
763 |
+
enter_btn = gr.Button("청신 의식 시작하기", variant="primary")
|
764 |
+
|
765 |
+
with gr.TabItem("청신") as tab_listen:
|
766 |
+
gr.Markdown("## 청신 - 소리로 정화하기")
|
767 |
+
gr.Markdown(
|
768 |
+
"""
|
769 |
+
온천천의 소리를 들으며 마음을 정화해보세요.
|
770 |
+
|
771 |
+
💫 이 앱은 온천천의 사운드스케이프를 녹음하여 제작되었으며,
|
772 |
+
온천천 온천장역에서 장전역까지 걸으며 더 깊은 체험이 가능합니다.
|
773 |
+
"""
|
774 |
+
)
|
775 |
+
play_music_btn = gr.Button("온천천의 소리 듣기", variant="secondary")
|
776 |
+
with gr.Row():
|
777 |
+
audio = gr.Audio(
|
778 |
+
value="assets/main_music.mp3",
|
779 |
+
type="filepath",
|
780 |
+
label="온천천의 소리",
|
781 |
+
interactive=False,
|
782 |
+
show_download_button=True,
|
783 |
+
visible=True
|
784 |
+
)
|
785 |
+
with gr.Column():
|
786 |
+
reflection_input = gr.Textbox(
|
787 |
+
label="지금 이 순간의 감상을 자유롭게 적어보세요",
|
788 |
+
lines=3,
|
789 |
+
max_lines=5
|
790 |
+
)
|
791 |
+
save_btn = gr.Button("감상 저장하기", variant="secondary")
|
792 |
+
reflections_display = gr.Dataframe(
|
793 |
+
headers=["시간", "감상", "감정 분석"],
|
794 |
+
label="기록된 감상들",
|
795 |
+
value=[], # 초기값은 빈 리스트
|
796 |
+
interactive=False,
|
797 |
+
wrap=True,
|
798 |
+
row_count=(5, "dynamic") # 동적으로 행 수 조정
|
799 |
+
)
|
800 |
+
|
801 |
|
802 |
# 기원 탭
|
803 |
with gr.TabItem("기원") as tab_wish:
|