Spaces:
Sleeping
Sleeping
Commit ·
6443613
1
Parent(s): 66d57ca
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,24 +151,23 @@ if submit:
|
|
| 151 |
# Display conversation history
|
| 152 |
for message in st.session_state['flowmessages']:
|
| 153 |
if isinstance(message, AIMessage):
|
| 154 |
-
|
| 155 |
-
st.
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
st.audio(audio_response.content,format="audio/wav",start_time=0)
|
| 172 |
|
| 173 |
|
| 174 |
|
|
|
|
| 151 |
# Display conversation history
|
| 152 |
for message in st.session_state['flowmessages']:
|
| 153 |
if isinstance(message, AIMessage):
|
| 154 |
+
# Display Doctor AI's response header and content
|
| 155 |
+
doctor_ai_header = st.header("Doctor AI", divider=True)
|
| 156 |
+
doctor_ai_content = st.write(message.content)
|
| 157 |
+
|
| 158 |
+
# Add a button to play the audio
|
| 159 |
+
if st.button("🔊 Play Audio", key="audio_button"):
|
| 160 |
+
# Text-to-speech
|
| 161 |
+
audio_response = openai.audio.speech.create(
|
| 162 |
+
model="tts-1",
|
| 163 |
+
voice="nova",
|
| 164 |
+
input=response,
|
| 165 |
+
response_format="mp3",
|
| 166 |
+
speed=1.0
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
# Play the audio
|
| 170 |
+
st.audio(audio_response.content, format="audio/wav", start_time=0)
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
|