Spaces:
Sleeping
Sleeping
Commit ·
b2c635f
1
Parent(s): 201a42a
Update app.py
Browse files32 unmodified lines33343536373839404142434445464748495051525336373822 unmodified lines616263826465666768697071727374757677787980818232 unmodified lines st.markdown(message['content']) ## messages element format: {'role':'user', 'content':'<user prompt>'} if st.session_state.messages==[]: for gr in greetings: with st.chat_message("assistant"): st.markdown(gr)
tts=gTTS(gr) tts.save(audio_stream) with open(audio_stream, 'rb') as file: audio_data=file.read() audio_base64 = base64.b64encode(audio_data).decode('utf-8') audio_tag = f'<audio autoplay="true" src="data:audio/mp3;base64,{audio_base64}">' st.markdown(audio_tag, unsafe_allow_html=True) time.sleep(10) st.session_state.messages.append({ 'role':'assistant', 'content': gr})
tts=gTTS("Here is your answer")tts.save(audio_stream)22 unmodified lines st.session_state.messages.append({ 'role':'assistant', 'content': response}) 'content': response})
if st.session_state.messages==[]: for gr in greetings: with st.chat_message("assistant"): st.markdown(gr)
tts=gTTS(gr) tts.save(audio_stream) with open(audio_stream, 'rb') as file: audio_data=file.read() audio_base64 = base64.b64encode(audio_data).decode('utf-8') audio_tag = f'<audio autoplay="true" src="data:audio/mp3;base64,{audio_base64}">' st.markdown(audio_tag, unsafe_allow_html=True) time.sleep(10) st.session_state.messages.append({ 'role':'assistant', 'content': gr})app.py+19-19