SaileshSivan commited on
Commit
6443613
·
1 Parent(s): 66d57ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
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
- st.header("Doctor AI", divider=True)
155
- st.write(message.content)
156
- elif isinstance(message, HumanMessage):
157
- st.header(":blue[You]", divider=True)
158
- st.write(message.content)
159
-
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
- # Embed audio in the webpage without saving it
170
- st.header(':blue[Listen or Download] :loud_sound:')
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