rishikesh commited on
Commit
38805e8
·
1 Parent(s): da94139

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -36,10 +36,22 @@ def main():
36
  st.write(generated_text)
37
  generated_audio = gTTS(generated_text)
38
  generated_audio.save('demo.mp3')
39
- playsound('demo.mp3')
40
- audio_file = open('demo.mp3', 'rb')
41
- audio_bytes = audio_file.read()
42
- st.audio(audio_bytes, format='audio/ogg',start_time=0)
 
 
 
 
 
 
 
 
 
 
43
 
44
  if __name__ == '__main__' :
45
- main()
 
 
 
36
  st.write(generated_text)
37
  generated_audio = gTTS(generated_text)
38
  generated_audio.save('demo.mp3')
39
+ html_string = """
40
+ <audio controls autoplay>
41
+ <source src="demo.mp3" type="audio/mp3">
42
+ </audio>
43
+ """
44
+
45
+ sound = st.empty()
46
+ sound.markdown(html_string, unsafe_allow_html=True) # will display a st.audio with the sound you specified in the "src" of the
47
+ # html_string and autoplay it
48
+ time.sleep(2) # wait for 2 seconds to finish the playing of the audio
49
+ # sound.empty()
50
+ #audio_file = open('demo.mp3', 'rb')
51
+ #audio_bytes = audio_file.read()
52
+ #st.audio(audio_bytes, format='audio/ogg',start_time=0)
53
 
54
  if __name__ == '__main__' :
55
+ main()
56
+
57
+ # optionally delete the element afterwards