Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from gtts import gTTS
|
| 3 |
-
from pydub import AudioSegment
|
| 4 |
-
from pydub.playback import play
|
| 5 |
import tempfile
|
| 6 |
import os
|
| 7 |
|
|
@@ -24,16 +22,13 @@ def create_audio_for_student(student):
|
|
| 24 |
tts.save(temp_file.name)
|
| 25 |
return temp_file.name
|
| 26 |
|
| 27 |
-
# νμ¬ νμ μ΄λ¦ κ°μ Έμ€κΈ°
|
| 28 |
-
current_student = student_list[st.session_state.current_index]
|
| 29 |
-
|
| 30 |
# νμ μ΄λ¦ λΆλ¬μ€κΈ°
|
| 31 |
if st.button("λ€μ νμ"):
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
audio_file = create_audio_for_student(current_student)
|
| 34 |
-
audio =
|
| 35 |
-
play(audio)
|
| 36 |
-
os.remove(audio_file) # μμ νμΌ μμ
|
| 37 |
|
| 38 |
# νλ©΄μ νμ¬ νμ μ΄λ¦ νμ
|
| 39 |
st.subheader(f"νμ¬ νμ: {current_student}")
|
|
@@ -50,6 +45,9 @@ if st.button("λ€μ νμ"):
|
|
| 50 |
st.session_state.current_index += 1
|
| 51 |
else:
|
| 52 |
st.write("λͺ¨λ νμμ μ΄λ¦μ λΆλ μ΅λλ€.")
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# κ²°μμ 리μ€νΈ 보μ¬μ£ΌκΈ°
|
| 55 |
st.subheader("κ²°μμ 리μ€νΈ")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from gtts import gTTS
|
|
|
|
|
|
|
| 3 |
import tempfile
|
| 4 |
import os
|
| 5 |
|
|
|
|
| 22 |
tts.save(temp_file.name)
|
| 23 |
return temp_file.name
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
# νμ μ΄λ¦ λΆλ¬μ€κΈ°
|
| 26 |
if st.button("λ€μ νμ"):
|
| 27 |
+
current_student = student_list[st.session_state.current_index]
|
| 28 |
+
|
| 29 |
+
# μ€λμ€ νμΌ μμ± λ° μ¬μ
|
| 30 |
audio_file = create_audio_for_student(current_student)
|
| 31 |
+
st.audio(audio_file, format='audio/mp3', start_time=0)
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# νλ©΄μ νμ¬ νμ μ΄λ¦ νμ
|
| 34 |
st.subheader(f"νμ¬ νμ: {current_student}")
|
|
|
|
| 45 |
st.session_state.current_index += 1
|
| 46 |
else:
|
| 47 |
st.write("λͺ¨λ νμμ μ΄λ¦μ λΆλ μ΅λλ€.")
|
| 48 |
+
|
| 49 |
+
# μμ νμΌ μμ
|
| 50 |
+
os.remove(audio_file)
|
| 51 |
|
| 52 |
# κ²°μμ 리μ€νΈ 보μ¬μ£ΌκΈ°
|
| 53 |
st.subheader("κ²°μμ 리μ€νΈ")
|