Spaces:
Sleeping
Sleeping
Commit
Β·
3b8077c
1
Parent(s):
6443613
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,6 +140,7 @@ if clear_chat_button:
|
|
| 140 |
# Clear the entire session and chat
|
| 141 |
st.session_state['flowmessages'] = []
|
| 142 |
|
|
|
|
| 143 |
# If the "Submit" button is clicked
|
| 144 |
if submit:
|
| 145 |
# Display loading message while processing
|
|
@@ -151,23 +152,28 @@ if submit:
|
|
| 151 |
# Display conversation history
|
| 152 |
for message in st.session_state['flowmessages']:
|
| 153 |
if isinstance(message, AIMessage):
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
|
|
|
|
| 140 |
# Clear the entire session and chat
|
| 141 |
st.session_state['flowmessages'] = []
|
| 142 |
|
| 143 |
+
# If the "Submit" button is clicked
|
| 144 |
# If the "Submit" button is clicked
|
| 145 |
if submit:
|
| 146 |
# Display loading message while processing
|
|
|
|
| 152 |
# Display conversation history
|
| 153 |
for message in st.session_state['flowmessages']:
|
| 154 |
if isinstance(message, AIMessage):
|
| 155 |
+
st.header("Doctor AI π", divider=True)
|
| 156 |
+
st.write(message.content)
|
| 157 |
+
elif isinstance(message, HumanMessage):
|
| 158 |
+
st.header(":blue[You]", divider=True)
|
| 159 |
+
st.write(message.content)
|
| 160 |
+
|
| 161 |
+
# Text-to-speech
|
| 162 |
+
audio_response = openai.audio.speech.create(
|
| 163 |
+
model="tts-1",
|
| 164 |
+
voice="nova",
|
| 165 |
+
input=response,
|
| 166 |
+
response_format="mp3",
|
| 167 |
+
speed=1.0
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
# Embed audio in the webpage without saving it
|
| 171 |
+
st.header(':blue[Listen or Download] :loud_sound:')
|
| 172 |
+
|
| 173 |
+
# Check if the "π" button is clicked
|
| 174 |
+
if st.button("π Play Audio"):
|
| 175 |
+
st.audio(audio_response.content, format="audio/mp3", start_time=0)
|
| 176 |
+
|
| 177 |
|
| 178 |
|
| 179 |
|