Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -119,11 +119,14 @@ def launch_bot():
|
|
| 119 |
st.write("Convert to Audio 🔊")
|
| 120 |
with st.popover("Open Audio"):
|
| 121 |
message2 = {"role": "assistant", "content": "Converting text to speech. This may take a few minutes."}
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
|
| 129 |
|
|
|
|
| 119 |
st.write("Convert to Audio 🔊")
|
| 120 |
with st.popover("Open Audio"):
|
| 121 |
message2 = {"role": "assistant", "content": "Converting text to speech. This may take a few minutes."}
|
| 122 |
+
# Create temporary file for audio
|
| 123 |
+
with tempfile.NamedTemporaryFile(suffix=".mp3") as temp_file:
|
| 124 |
+
tts = gTTS('Add text-to-speech to your app', lang='en')
|
| 125 |
+
tts.write_to_fp(temp_file)
|
| 126 |
+
temp_file.seek(0) # rewind the file pointer
|
| 127 |
+
|
| 128 |
+
# Play the audio file
|
| 129 |
+
st.audio(temp_file)
|
| 130 |
|
| 131 |
|
| 132 |
|