randmimc commited on
Commit
e11efe5
ยท
verified ยท
1 Parent(s): e8655b1

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +23 -17
src/streamlit_app.py CHANGED
@@ -61,28 +61,34 @@ def display_status_and_action(text):
61
 
62
  # ์˜ค๋””์˜ค ์ŠคํŠธ๋ฆผ ์žฌ์„ค์ • ํ›„ ์žฌ์ƒ
63
  mp3_fp.seek(0)
64
- # CSS๋ฅผ ์ด์šฉํ•ด ์„ธ๋กœ ์ •๋ ฌ ๋ฐ help ์ œ๊ฑฐ ์Šคํƒ€์ผ ์ ์šฉ
65
- st.markdown("""
 
 
 
 
 
66
  <style>
67
- .audio-container {
68
- display: flex;
69
- align-items: center;
70
- gap: 10px;
71
- }
72
- .audio-icon {
73
- font-size: 30px;
74
- }
75
  </style>
76
  <div class="audio-container">
77
  <div class="audio-icon">๐Ÿ”Š</div>
78
- <div class="audio-player">
79
- """, unsafe_allow_html=True)
80
-
81
- # st.audio ์‚ฝ์ž…
82
- st.audio(mp3_fp, format="audio/mp3")
 
83
 
84
- # ๋‹ซ๋Š” div
85
- st.markdown("</div></div>", unsafe_allow_html=True)
86
 
87
  # ์ƒํƒœ ๋ฐ ์กฐ์น˜ ์ถœ๋ ฅ
88
  display_status_and_action(selected_text)
 
61
 
62
  # ์˜ค๋””์˜ค ์ŠคํŠธ๋ฆผ ์žฌ์„ค์ • ํ›„ ์žฌ์ƒ
63
  mp3_fp.seek(0)
64
+
65
+ # Base64 ์ธ์ฝ”๋”ฉ
66
+ audio_bytes = mp3_fp.read()
67
+ audio_base64 = base64.b64encode(audio_bytes).decode()
68
+
69
+ # HTML ์Šคํƒ€์ผ ๋ฐ ์˜ค๋””์˜ค ์ถœ๋ ฅ
70
+ audio_html = f"""
71
  <style>
72
+ .audio-container {{
73
+ display: flex;
74
+ align-items: center;
75
+ gap: 10px;
76
+ }}
77
+ .audio-icon {{
78
+ font-size: 30px;
79
+ }}
80
  </style>
81
  <div class="audio-container">
82
  <div class="audio-icon">๐Ÿ”Š</div>
83
+ <audio controls>
84
+ <source src="data:audio/mp3;base64,{audio_base64}" type="audio/mp3">
85
+ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์˜ค๋””์˜ค ํƒœ๊ทธ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
86
+ </audio>
87
+ </div>
88
+ """
89
 
90
+ # HTML ๋ Œ๋”๋ง
91
+ st.markdown(audio_html, unsafe_allow_html=True)
92
 
93
  # ์ƒํƒœ ๋ฐ ์กฐ์น˜ ์ถœ๋ ฅ
94
  display_status_and_action(selected_text)