Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
from pydub import AudioSegment
|
| 4 |
-
from pydub.playback import play
|
| 5 |
-
import tempfile
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
# νμ 리μ€νΈ
|
| 9 |
student_list = ["νκΈΈλ", "κΉμ² μ", "μ΄μν¬", "λ°μμ"]
|
|
@@ -15,30 +11,27 @@ attendance_status = {student: "λ―ΈνμΈ" for student in student_list}
|
|
| 15 |
# Streamlit UI
|
| 16 |
st.title("μΆμ νμΈ μμ€ν
")
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
if 'current_index' not in st.session_state:
|
| 19 |
st.session_state.current_index = 0
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
def
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
tts.save(temp_file.name)
|
| 26 |
-
return temp_file.name
|
| 27 |
|
| 28 |
# νμ μ΄λ¦ λΆλ¬μ€κΈ°
|
| 29 |
if st.button("λ€μ νμ"):
|
| 30 |
current_student = student_list[st.session_state.current_index]
|
| 31 |
|
| 32 |
-
# μ€λμ€ νμΌ μμ±
|
| 33 |
-
audio_file = create_audio_for_student(current_student)
|
| 34 |
-
|
| 35 |
-
# μ€λμ€ νμΌμ μλ μ¬μ
|
| 36 |
-
audio_segment = AudioSegment.from_mp3(audio_file)
|
| 37 |
-
play(audio_segment)
|
| 38 |
-
|
| 39 |
# νλ©΄μ νμ¬ νμ μ΄λ¦ νμ
|
| 40 |
st.subheader(f"νμ¬ νμ: {current_student}")
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
# μΆμ μ¬λΆ μ ν
|
| 43 |
attendance = st.radio(f"{current_student} μΆμ μ¬λΆ", ("μΆμ", "κ²°μ"))
|
| 44 |
attendance_status[current_student] = attendance
|
|
@@ -56,9 +49,6 @@ if st.button("λ€μ νμ"):
|
|
| 56 |
st.session_state.current_index += 1
|
| 57 |
else:
|
| 58 |
st.write("λͺ¨λ νμμ μ΄λ¦μ λΆλ μ΅λλ€.")
|
| 59 |
-
|
| 60 |
-
# μμ νμΌ μμ
|
| 61 |
-
os.remove(audio_file)
|
| 62 |
|
| 63 |
# κ²°μμ 리μ€νΈ 보μ¬μ£ΌκΈ°
|
| 64 |
st.subheader("κ²°μμ 리μ€νΈ")
|
|
@@ -66,3 +56,4 @@ if absentees:
|
|
| 66 |
st.write(absentees)
|
| 67 |
else:
|
| 68 |
st.write("κ²°μμκ° μμ΅λλ€.")
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pyttsx3
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# νμ 리μ€νΈ
|
| 5 |
student_list = ["νκΈΈλ", "κΉμ² μ", "μ΄μν¬", "λ°μμ"]
|
|
|
|
| 11 |
# Streamlit UI
|
| 12 |
st.title("μΆμ νμΈ μμ€ν
")
|
| 13 |
|
| 14 |
+
# TTS μμ§ μ΄κΈ°ν
|
| 15 |
+
engine = pyttsx3.init()
|
| 16 |
+
|
| 17 |
if 'current_index' not in st.session_state:
|
| 18 |
st.session_state.current_index = 0
|
| 19 |
|
| 20 |
+
# TTSλ‘ μ΄λ¦ μ½μ΄μ£Όλ ν¨μ
|
| 21 |
+
def speak_text(text):
|
| 22 |
+
engine.say(text)
|
| 23 |
+
engine.runAndWait()
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# νμ μ΄λ¦ λΆλ¬μ€κΈ°
|
| 26 |
if st.button("λ€μ νμ"):
|
| 27 |
current_student = student_list[st.session_state.current_index]
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# νλ©΄μ νμ¬ νμ μ΄λ¦ νμ
|
| 30 |
st.subheader(f"νμ¬ νμ: {current_student}")
|
| 31 |
|
| 32 |
+
# νμ μ΄λ¦μ TTSλ‘ μ½κΈ°
|
| 33 |
+
speak_text(current_student + " νμ")
|
| 34 |
+
|
| 35 |
# μΆμ μ¬λΆ μ ν
|
| 36 |
attendance = st.radio(f"{current_student} μΆμ μ¬λΆ", ("μΆμ", "κ²°μ"))
|
| 37 |
attendance_status[current_student] = attendance
|
|
|
|
| 49 |
st.session_state.current_index += 1
|
| 50 |
else:
|
| 51 |
st.write("λͺ¨λ νμμ μ΄λ¦μ λΆλ μ΅λλ€.")
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
# κ²°μμ 리μ€νΈ 보μ¬μ£ΌκΈ°
|
| 54 |
st.subheader("κ²°μμ 리μ€νΈ")
|
|
|
|
| 56 |
st.write(absentees)
|
| 57 |
else:
|
| 58 |
st.write("κ²°μμκ° μμ΅λλ€.")
|
| 59 |
+
|