Update app.py
Browse files
app.py
CHANGED
@@ -582,7 +582,7 @@ def safe_state_update(state, updates):
|
|
582 |
return state
|
583 |
|
584 |
def create_interface():
|
585 |
-
db = SimpleDB()
|
586 |
import base64
|
587 |
|
588 |
# initial_state 정의
|
@@ -593,8 +593,7 @@ def create_interface():
|
|
593 |
"wish": None,
|
594 |
"final_prompt": "",
|
595 |
"image_path": None,
|
596 |
-
"current_tab": 0
|
597 |
-
"audio_playing": False
|
598 |
}
|
599 |
|
600 |
def encode_image_to_base64(image_path):
|
@@ -627,78 +626,6 @@ def create_interface():
|
|
627 |
<img src="data:image/png;base64,{main_image}" alt="디지털 굿판 메인 이미지" class="main-image">
|
628 |
</div>
|
629 |
"""
|
630 |
-
|
631 |
-
# HTML5 Audio Player 템플릿
|
632 |
-
AUDIO_PLAYER_HTML = """
|
633 |
-
<div class="audio-player-container">
|
634 |
-
<audio id="mainAudio" preload="auto" style="display:none;">
|
635 |
-
<source src="/assets/main_music.mp3" type="audio/mp3">
|
636 |
-
</audio>
|
637 |
-
<button id="playButton" onclick="toggleAudio()" class="custom-audio-button">
|
638 |
-
<span id="playButtonText">재생</span>
|
639 |
-
</button>
|
640 |
-
</div>
|
641 |
-
<script>
|
642 |
-
let audio = document.getElementById('mainAudio');
|
643 |
-
let playButton = document.getElementById('playButton');
|
644 |
-
let playButtonText = document.getElementById('playButtonText');
|
645 |
-
|
646 |
-
function toggleAudio() {
|
647 |
-
if (audio.paused) {
|
648 |
-
audio.play().then(() => {
|
649 |
-
playButtonText.textContent = '일시정지';
|
650 |
-
}).catch(error => {
|
651 |
-
console.error('Audio playback failed:', error);
|
652 |
-
alert('음악 재생에 실패했습니다. 다시 시도해주세요.');
|
653 |
-
});
|
654 |
-
} else {
|
655 |
-
audio.pause();
|
656 |
-
playButtonText.textContent = '재생';
|
657 |
-
}
|
658 |
-
}
|
659 |
-
|
660 |
-
audio.addEventListener('ended', () => {
|
661 |
-
playButtonText.textContent = '재생';
|
662 |
-
});
|
663 |
-
|
664 |
-
audio.addEventListener('error', (e) => {
|
665 |
-
console.error('Audio error:', e);
|
666 |
-
alert('음악 파일을 불러오는데 실패했습니다.');
|
667 |
-
});
|
668 |
-
</script>
|
669 |
-
<style>
|
670 |
-
.audio-player-container {
|
671 |
-
margin: 20px 0;
|
672 |
-
width: 100%;
|
673 |
-
text-align: center;
|
674 |
-
}
|
675 |
-
.custom-audio-button {
|
676 |
-
width: 200px;
|
677 |
-
padding: 12px 24px;
|
678 |
-
margin: 10px 0;
|
679 |
-
background-color: #4a90e2;
|
680 |
-
color: white;
|
681 |
-
border: none;
|
682 |
-
border-radius: 8px;
|
683 |
-
cursor: pointer;
|
684 |
-
font-size: 16px;
|
685 |
-
font-weight: bold;
|
686 |
-
transition: background-color 0.3s ease;
|
687 |
-
}
|
688 |
-
.custom-audio-button:hover {
|
689 |
-
background-color: #357abd;
|
690 |
-
}
|
691 |
-
.custom-audio-button:active {
|
692 |
-
background-color: #2a5d8f;
|
693 |
-
transform: scale(0.98);
|
694 |
-
}
|
695 |
-
@media (max-width: 600px) {
|
696 |
-
.custom-audio-button {
|
697 |
-
width: 100%;
|
698 |
-
}
|
699 |
-
}
|
700 |
-
</style>
|
701 |
-
"""
|
702 |
|
703 |
css = """
|
704 |
/* 전체 컨테이너 width 제한 */
|
@@ -885,12 +812,9 @@ def create_interface():
|
|
885 |
|
886 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
887 |
state = gr.State(value=initial_state)
|
888 |
-
processing_status = gr.State("")
|
889 |
with gr.Column(elem_classes="logo-container"):
|
890 |
-
gr.HTML(
|
891 |
-
<img class="mobile-logo" src="data:image/png;base64,{mobile_logo}" alt="디지털 굿판 로고 모바일">
|
892 |
-
<img class="desktop-logo" src="data:image/png;base64,{desktop_logo}" alt="디지털 굿판 로고 데스크톱">
|
893 |
-
""")
|
894 |
|
895 |
with gr.Tabs(selected=0) as tabs:
|
896 |
# 입장 탭 (축원 포함)
|
@@ -1352,12 +1276,7 @@ def create_interface():
|
|
1352 |
set_baseline_btn.click(
|
1353 |
fn=handle_blessing_complete,
|
1354 |
inputs=[baseline_audio, state],
|
1355 |
-
outputs=[
|
1356 |
-
state,
|
1357 |
-
blessing_status,
|
1358 |
-
analysis_complete,
|
1359 |
-
continue_to_next
|
1360 |
-
]
|
1361 |
)
|
1362 |
|
1363 |
continue_to_next.click(
|
|
|
582 |
return state
|
583 |
|
584 |
def create_interface():
|
585 |
+
db = SimpleDB()
|
586 |
import base64
|
587 |
|
588 |
# initial_state 정의
|
|
|
593 |
"wish": None,
|
594 |
"final_prompt": "",
|
595 |
"image_path": None,
|
596 |
+
"current_tab": 0
|
|
|
597 |
}
|
598 |
|
599 |
def encode_image_to_base64(image_path):
|
|
|
626 |
<img src="data:image/png;base64,{main_image}" alt="디지털 굿판 메인 이미지" class="main-image">
|
627 |
</div>
|
628 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
|
630 |
css = """
|
631 |
/* 전체 컨테이너 width 제한 */
|
|
|
812 |
|
813 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
814 |
state = gr.State(value=initial_state)
|
815 |
+
processing_status = gr.State("")
|
816 |
with gr.Column(elem_classes="logo-container"):
|
817 |
+
gr.HTML(logo_html)
|
|
|
|
|
|
|
818 |
|
819 |
with gr.Tabs(selected=0) as tabs:
|
820 |
# 입장 탭 (축원 포함)
|
|
|
1276 |
set_baseline_btn.click(
|
1277 |
fn=handle_blessing_complete,
|
1278 |
inputs=[baseline_audio, state],
|
1279 |
+
outputs=[state, blessing_status]
|
|
|
|
|
|
|
|
|
|
|
1280 |
)
|
1281 |
|
1282 |
continue_to_next.click(
|