randmimc commited on
Commit
4a6a60c
·
verified ·
1 Parent(s): 3a13827

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +18 -3
src/streamlit_app.py CHANGED
@@ -24,6 +24,21 @@ options = [
24
  selected_text = st.selectbox("데이터를 선택하세요", options)
25
  print(selected_text)
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  # 데이터 상태 및 조치 상황 표시 함수
28
  def display_status_and_action(text):
29
  if text == "":
@@ -36,18 +51,18 @@ def display_status_and_action(text):
36
  warning = "⚠️ 일정 수치 이상의 Soot 축적량이 2시간 이상 지속되는 현상을 보임. \nSoot 가 일정수치에 도달했을때 정상적으로 연소되지 않거나, 센서 불량으로 인해 Dosing 이 과하게 활성화됨. \nsoot 가 증가하는 과정에서 불규칙적인 증감 현상이 발생함. \n튐 또는 비선형 형태가 크게 나타남. \nSoot 의 축적량이 40을 초과하는 구간이 존재함."
37
  st.warning(warning)
38
  st.markdown(text_input)
 
 
39
 
40
- if st.button("🎤", help="음성으로 듣기"):
41
  text_input = warning + " " + text_input
42
  cleaned_text = re.sub(r'[\x00-\x1F]+', '', text_input).replace("*", "")
43
  tts = gTTS(text=cleaned_text, lang='ko')
44
  mp3_fp = BytesIO()
45
  tts.write_to_fp(mp3_fp)
46
-
47
- # 오디오 스트림 재설정 후 재생
48
  mp3_fp.seek(0)
49
  st.audio(mp3_fp, format="audio/mp3")
50
 
 
51
 
52
  # 상태 및 조치 출력
53
  display_status_and_action(selected_text)
 
24
  selected_text = st.selectbox("데이터를 선택하세요", options)
25
  print(selected_text)
26
 
27
+ button_html = """
28
+ <style>
29
+ .icon-button {
30
+ background: none;
31
+ border: none;
32
+ font-size: 32px;
33
+ cursor: pointer;
34
+ }
35
+ </style>
36
+ <form action="" method="post">
37
+ <button class="icon-button" type="submit" name="mic">🎤</button>
38
+ </form>
39
+ """
40
+ st.markdown(button_html, unsafe_allow_html=True)
41
+
42
  # 데이터 상태 및 조치 상황 표시 함수
43
  def display_status_and_action(text):
44
  if text == "":
 
51
  warning = "⚠️ 일정 수치 이상의 Soot 축적량이 2시간 이상 지속되는 현상을 보임. \nSoot 가 일정수치에 도달했을때 정상적으로 연소되지 않거나, 센서 불량으로 인해 Dosing 이 과하게 활성화됨. \nsoot 가 증가하는 과정에서 불규칙적인 증감 현상이 발생함. \n튐 또는 비선형 형태가 크게 나타남. \nSoot 의 축적량이 40을 초과하는 구간이 존재함."
52
  st.warning(warning)
53
  st.markdown(text_input)
54
+ # 버튼 클릭 처리
55
+ if st.session_state.get("mic", False) or st.experimental_get_query_params().get("mic"):
56
 
 
57
  text_input = warning + " " + text_input
58
  cleaned_text = re.sub(r'[\x00-\x1F]+', '', text_input).replace("*", "")
59
  tts = gTTS(text=cleaned_text, lang='ko')
60
  mp3_fp = BytesIO()
61
  tts.write_to_fp(mp3_fp)
 
 
62
  mp3_fp.seek(0)
63
  st.audio(mp3_fp, format="audio/mp3")
64
 
65
+
66
 
67
  # 상태 및 조치 출력
68
  display_status_and_action(selected_text)