Update app.py
Browse files
app.py
CHANGED
@@ -622,7 +622,7 @@ def create_interface():
|
|
622 |
AUDIO_PLAYER_HTML = """
|
623 |
<div class="audio-player-container">
|
624 |
<audio id="mainAudio" preload="auto" style="display:none;">
|
625 |
-
<source src="/assets/main_music.mp3" type="audio/
|
626 |
</audio>
|
627 |
<button id="playButton" onclick="toggleAudio()" class="custom-audio-button">
|
628 |
<span id="playButtonText">재생</span>
|
@@ -843,14 +843,26 @@ def create_interface():
|
|
843 |
with blessing_section:
|
844 |
gr.Markdown("### 축원의식을 시작하겠습니다")
|
845 |
gr.Markdown("'명짐 복짐 짊어지고 안가태평하시기를 비도발원 축원 드립니다'")
|
|
|
|
|
846 |
baseline_audio = gr.Audio(
|
847 |
label="축원 문장 녹음하기",
|
848 |
sources=["microphone"],
|
849 |
type="numpy",
|
850 |
streaming=False
|
851 |
)
|
852 |
-
|
853 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
|
855 |
# 4단계: 굿판 입장 안내
|
856 |
entry_guide_section = gr.Column(visible=False)
|
@@ -1003,31 +1015,21 @@ def create_interface():
|
|
1003 |
def handle_blessing_complete(audio, state):
|
1004 |
if audio is None:
|
1005 |
return state, "음성을 먼저 녹음해주세요.", gr.update(visible=True), gr.update(visible=False)
|
1006 |
-
|
1007 |
try:
|
1008 |
-
|
1009 |
-
status_msg = "축원 분석 중..."
|
1010 |
-
|
1011 |
-
# 음성 분석 수행
|
1012 |
sr, y = audio
|
1013 |
features = calculate_baseline_features((sr, y))
|
1014 |
|
1015 |
if features:
|
1016 |
-
state = safe_state_update(state, {
|
1017 |
-
|
1018 |
-
|
1019 |
-
status_msg = "축원이 완료되었습니다."
|
1020 |
-
return (
|
1021 |
-
state,
|
1022 |
-
status_msg,
|
1023 |
-
gr.update(visible=False),
|
1024 |
-
gr.update(visible=True)
|
1025 |
-
)
|
1026 |
-
|
1027 |
-
return state, "축원 분석에 실패했습니다.", gr.update(visible=True), gr.update(visible=False)
|
1028 |
|
|
|
|
|
1029 |
except Exception as e:
|
1030 |
-
return state, f"
|
1031 |
|
1032 |
def handle_enter():
|
1033 |
return gr.update(selected=1) # 청신 탭으로 이동
|
|
|
622 |
AUDIO_PLAYER_HTML = """
|
623 |
<div class="audio-player-container">
|
624 |
<audio id="mainAudio" preload="auto" style="display:none;">
|
625 |
+
<source src="/assets/main_music.mp3" type="audio/mp3">
|
626 |
</audio>
|
627 |
<button id="playButton" onclick="toggleAudio()" class="custom-audio-button">
|
628 |
<span id="playButtonText">재생</span>
|
|
|
843 |
with blessing_section:
|
844 |
gr.Markdown("### 축원의식을 시작하겠습니다")
|
845 |
gr.Markdown("'명짐 복짐 짊어지고 안가태평하시기를 비도발원 축원 드립니다'")
|
846 |
+
|
847 |
+
# 축원 문장 녹음하기
|
848 |
baseline_audio = gr.Audio(
|
849 |
label="축원 문장 녹음하기",
|
850 |
sources=["microphone"],
|
851 |
type="numpy",
|
852 |
streaming=False
|
853 |
)
|
854 |
+
|
855 |
+
# 상태 표시 (길이 조정 추가)
|
856 |
+
blessing_status = gr.Markdown(
|
857 |
+
"분석 결과가 여기에 표시됩니다.",
|
858 |
+
elem_id="blessing-status",
|
859 |
+
style={"min-height": "200px"} # CSS 스타일로 길이를 조정합니다
|
860 |
+
)
|
861 |
+
|
862 |
+
# 상태 분석 및 결과창 구분
|
863 |
+
set_baseline_btn = gr.Button("축원문 분석하기", variant="primary")
|
864 |
+
send_blessing_btn = gr.Button("축원 보내기", variant="secondary", visible=False)
|
865 |
+
|
866 |
|
867 |
# 4단계: 굿판 입장 안내
|
868 |
entry_guide_section = gr.Column(visible=False)
|
|
|
1015 |
def handle_blessing_complete(audio, state):
|
1016 |
if audio is None:
|
1017 |
return state, "음성을 먼저 녹음해주세요.", gr.update(visible=True), gr.update(visible=False)
|
1018 |
+
|
1019 |
try:
|
1020 |
+
status_msg = "축원문 분석 중..."
|
|
|
|
|
|
|
1021 |
sr, y = audio
|
1022 |
features = calculate_baseline_features((sr, y))
|
1023 |
|
1024 |
if features:
|
1025 |
+
state = safe_state_update(state, {"baseline_features": features})
|
1026 |
+
status_msg = "분석 완료되었습니다. 축원을 보내세요."
|
1027 |
+
return state, status_msg, gr.update(visible=False), gr.update(visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1028 |
|
1029 |
+
return state, "분석에 실패했습니다. 다시 시도해주세요.", gr.update(visible=True), gr.update(visible=False)
|
1030 |
+
|
1031 |
except Exception as e:
|
1032 |
+
return state, f"오류 발생: {str(e)}", gr.update(visible=True), gr.update(visible=False)
|
1033 |
|
1034 |
def handle_enter():
|
1035 |
return gr.update(selected=1) # 청신 탭으로 이동
|