haepada commited on
Commit
d0049ca
·
verified ·
1 Parent(s): 9300635

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -40
app.py CHANGED
@@ -52,9 +52,6 @@ def serve_assets(path):
52
  def serve_wishes(path):
53
  return send_from_directory('data/wishes', path)
54
 
55
- @app.route('/assets/<path:filename>')
56
- def serve_audio(filename):
57
- return send_from_directory('assets', filename, mimetype='audio/mp3')
58
 
59
  class SimpleDB:
60
  def __init__(self, reflections_path="data/reflections.json", wishes_path="data/wishes.json"):
@@ -950,42 +947,28 @@ def create_interface():
950
  """)
951
 
952
  # 커스텀 오디오 플레이어
953
- with gr.Blocks(css=css) as demo:
954
- gr.Markdown("## 聽身, 請神 (몸의 소리를 듣고 신을 청하다) ")
955
- # HTML로 오디오 플레이어를 직접 삽입
956
- gr.HTML("""
957
- <div class="audio-player-container">
958
- <audio id="bgMusic" controls="controls" style="width: 100%; max-width: 500px;">
959
- <source src="assets/main_music.mp3" type="audio/mpeg">
960
- </audio>
961
- </div>
962
- <script>
963
- // 변경을 감지하여 음악 재생
964
- document.addEventListener('DOMContentLoaded', function() {
965
- const audio = document.querySelector('#bgMusic');
966
- if(audio) {
967
- // 탭 진입 시 음악 재생
968
- audio.play().catch(function(error) {
969
- console.log("음악 자동재생 실패:", error);
970
- });
971
- }
972
- });
973
- </script>
974
- <style>
975
- .audio-player-container {
976
- width: 100%;
977
- margin: 20px auto;
978
- text-align: center;
979
- padding: 20px;
980
- }
981
- audio {
982
- width: 100%;
983
- max-width: 500px;
984
- margin: 0 auto;
985
- display: block;
986
- }
987
- </style>
988
- """)
989
 
990
  with gr.Column():
991
  reflection_input = gr.Textbox(
@@ -1325,7 +1308,7 @@ def create_interface():
1325
  )
1326
 
1327
  enter_btn.click(
1328
- fn=lambda: gr.Tabs.update(selected="청신"),
1329
  outputs=tabs
1330
  )
1331
 
 
52
  def serve_wishes(path):
53
  return send_from_directory('data/wishes', path)
54
 
 
 
 
55
 
56
  class SimpleDB:
57
  def __init__(self, reflections_path="data/reflections.json", wishes_path="data/wishes.json"):
 
947
  """)
948
 
949
  # 커스텀 오디오 플레이어
950
+ gr.Markdown("## 聽身, 請神 (몸의 소리를 듣고 신을 청하다) ")
951
+ gr.HTML("""
952
+ <div class="audio-player-container">
953
+ <audio controls autoplay style="width: 100%; max-width: 500px;">
954
+ <source src="/assets/main_music.mp3" type="audio/mpeg">
955
+ </audio>
956
+ </div>
957
+ <style>
958
+ .audio-player-container {
959
+ width: 100%;
960
+ margin: 20px auto;
961
+ text-align: center;
962
+ padding: 20px;
963
+ }
964
+ audio {
965
+ width: 100%;
966
+ max-width: 500px;
967
+ margin: 0 auto;
968
+ display: block;
969
+ }
970
+ </style>
971
+ """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972
 
973
  with gr.Column():
974
  reflection_input = gr.Textbox(
 
1308
  )
1309
 
1310
  enter_btn.click(
1311
+ fn=lambda: gr.update(selected=1), # 인덱스로 변경
1312
  outputs=tabs
1313
  )
1314