Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|