Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +6 -42
src/streamlit_app.py
CHANGED
|
@@ -33,8 +33,7 @@ def tts_engine(text):
|
|
| 33 |
# Base64 ์ธ์ฝ๋ฉ
|
| 34 |
audio_bytes = mp3_fp.read()
|
| 35 |
audio_base64 = base64.b64encode(audio_bytes).decode()
|
| 36 |
-
return audio_base64
|
| 37 |
-
|
| 38 |
|
| 39 |
def none_temp():
|
| 40 |
st.info("๋จผ์ ๋ฐ์ดํฐ๋ฅผ ์ ํํด ์ฃผ์ธ์")
|
|
@@ -44,48 +43,14 @@ def normal(df, col_name):
|
|
| 44 |
st.success("โ
์ฐจ๋ ์ํ: ์ ์")
|
| 45 |
st.markdown("**์กฐ์น ์ฌํญ:** ์ถ๊ฐ ์กฐ์น๋ ํ์ํ์ง ์์ต๋๋ค.")
|
| 46 |
|
| 47 |
-
def anormal(df, col_name, warning, text_input
|
| 48 |
# custom style
|
| 49 |
-
|
| 50 |
-
<style>
|
| 51 |
-
.audio-container {{
|
| 52 |
-
display: flex;
|
| 53 |
-
align-items: center;
|
| 54 |
-
gap: 10px;
|
| 55 |
-
justify-content: flex-end; /* ์ค๋ฅธ์ชฝ ์ ๋ ฌ */
|
| 56 |
-
margin-top: 10px;
|
| 57 |
-
}}
|
| 58 |
-
.audio-icon {{
|
| 59 |
-
font-size: 30px;
|
| 60 |
-
cursor: pointer;
|
| 61 |
-
}}
|
| 62 |
-
.audio-icon[title]:hover::after {{
|
| 63 |
-
content: attr(title);
|
| 64 |
-
position: absolute;
|
| 65 |
-
background: #333;
|
| 66 |
-
color: #fff;
|
| 67 |
-
padding: 5px 8px;
|
| 68 |
-
border-radius: 5px;
|
| 69 |
-
white-space: nowrap;
|
| 70 |
-
font-size: 12px;
|
| 71 |
-
top: -35px;
|
| 72 |
-
right: 0;
|
| 73 |
-
z-index: 999;
|
| 74 |
-
}}
|
| 75 |
-
</style>
|
| 76 |
-
|
| 77 |
-
<div class="audio-container">
|
| 78 |
-
<div class="audio-icon" title="์ ๋ด์ฉ์ ์์ฑ์ผ๋ก ๋ฃ๊ธฐ">๐</div>
|
| 79 |
-
<audio controls>
|
| 80 |
-
<source src="data:audio/mp3;base64,{audio_base64}" type="audio/mp3">
|
| 81 |
-
๋ธ๋ผ์ฐ์ ๊ฐ ์ค๋์ค ํ๊ทธ๋ฅผ ์ง์ํ์ง ์์ต๋๋ค.
|
| 82 |
-
</audio>
|
| 83 |
-
</div>
|
| 84 |
-
"""
|
| 85 |
chart_generate(df, col_name)
|
| 86 |
st.warning(warning)
|
| 87 |
st.markdown(text_input)
|
| 88 |
-
|
|
|
|
| 89 |
|
| 90 |
# ์๋น์ค ์คํ
|
| 91 |
# 1. session_state ์ด๊ธฐํ (์ฑ์ด ์ฒ์ ์คํ๋ ๋๋ง ์๋)
|
|
@@ -101,7 +66,6 @@ if st.session_state.selection == "":
|
|
| 101 |
none_temp()
|
| 102 |
elif st.session_state.selection == "2024-09-26":
|
| 103 |
normal(df, "ECU_DPFSoot")
|
| 104 |
-
else:
|
| 105 |
-
audio_base64 = tts_engine(warning+" "+text_input)
|
| 106 |
anormal(df, "ECU_DPFSoot", warning, text_input, audio_base64)
|
| 107 |
|
|
|
|
| 33 |
# Base64 ์ธ์ฝ๋ฉ
|
| 34 |
audio_bytes = mp3_fp.read()
|
| 35 |
audio_base64 = base64.b64encode(audio_bytes).decode()
|
| 36 |
+
return mp3_fp, audio_base64
|
|
|
|
| 37 |
|
| 38 |
def none_temp():
|
| 39 |
st.info("๋จผ์ ๋ฐ์ดํฐ๋ฅผ ์ ํํด ์ฃผ์ธ์")
|
|
|
|
| 43 |
st.success("โ
์ฐจ๋ ์ํ: ์ ์")
|
| 44 |
st.markdown("**์กฐ์น ์ฌํญ:** ์ถ๊ฐ ์กฐ์น๋ ํ์ํ์ง ์์ต๋๋ค.")
|
| 45 |
|
| 46 |
+
def anormal(df, col_name, warning, text_input):
|
| 47 |
# custom style
|
| 48 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
chart_generate(df, col_name)
|
| 50 |
st.warning(warning)
|
| 51 |
st.markdown(text_input)
|
| 52 |
+
mp3_fp, audio_base64 = tts_engine(warning+" "+text_input)
|
| 53 |
+
st.audio(mp3_fp, format="audio/mp3")
|
| 54 |
|
| 55 |
# ์๋น์ค ์คํ
|
| 56 |
# 1. session_state ์ด๊ธฐํ (์ฑ์ด ์ฒ์ ์คํ๋ ๋๋ง ์๋)
|
|
|
|
| 66 |
none_temp()
|
| 67 |
elif st.session_state.selection == "2024-09-26":
|
| 68 |
normal(df, "ECU_DPFSoot")
|
| 69 |
+
else:
|
|
|
|
| 70 |
anormal(df, "ECU_DPFSoot", warning, text_input, audio_base64)
|
| 71 |
|