jonghhhh commited on
Commit
55445e1
Β·
verified Β·
1 Parent(s): 3455e4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
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 = AudioSegment.from_mp3(audio_file)
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("κ²°μ„μž 리슀트")