Spaces:
Sleeping
Sleeping
Commit
·
d3b0511
1
Parent(s):
44b3eba
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,13 +85,17 @@ if submit:
|
|
| 85 |
|
| 86 |
st.write(response)
|
| 87 |
# Text-to-speech
|
| 88 |
-
audio_response = openai.
|
| 89 |
-
|
| 90 |
-
text=response,
|
| 91 |
voice="alloy",
|
|
|
|
| 92 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
# Embed audio in the webpage
|
| 94 |
-
st.audio(
|
| 95 |
|
| 96 |
else:
|
| 97 |
st.subheader("Error: Unable to get response. Please try again later.")
|
|
|
|
| 85 |
|
| 86 |
st.write(response)
|
| 87 |
# Text-to-speech
|
| 88 |
+
audio_response = openai.audio.speech.create(
|
| 89 |
+
model="tts-1",
|
|
|
|
| 90 |
voice="alloy",
|
| 91 |
+
input=response
|
| 92 |
)
|
| 93 |
+
|
| 94 |
+
# Extract URL from binary response
|
| 95 |
+
audio_url = audio_response.content.decode("utf-8").splitlines()[0]
|
| 96 |
+
|
| 97 |
# Embed audio in the webpage
|
| 98 |
+
st.audio(audio_url)
|
| 99 |
|
| 100 |
else:
|
| 101 |
st.subheader("Error: Unable to get response. Please try again later.")
|