AchyuthGamer commited on
Commit
ac37763
1 Parent(s): 16a95dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  from gradio_client import Client
3
  from st_audiorec import st_audiorec
4
  from gtts import gTTS
5
- import os
6
 
7
  # Constants
8
  TITLE = "AgriTure"
@@ -86,8 +86,12 @@ if wav_audio_data is not None:
86
  # Convert AI response to speech
87
  speech_file = text_to_speech(response)
88
 
 
 
 
 
89
  # Play the generated speech
90
- st.audio(speech_file, format="audio/mp3")
91
 
92
  # Add assistant response to chat history
93
  st.session_state.messages.append({"role": "assistant", "content": response})
@@ -109,7 +113,7 @@ if prompt := textinput:
109
  st.markdown(response)
110
 
111
  # Play the generated speech
112
- st.audio(speech_file, format="audio/mp3")
113
 
114
  # Add assistant response to chat history
115
  st.session_state.messages.append({"role": "assistant", "content": response})
 
2
  from gradio_client import Client
3
  from st_audiorec import st_audiorec
4
  from gtts import gTTS
5
+ from IPython.display import Audio, display
6
 
7
  # Constants
8
  TITLE = "AgriTure"
 
86
  # Convert AI response to speech
87
  speech_file = text_to_speech(response)
88
 
89
+ # Display assistant response in chat message container
90
+ with st.chat_message("assistant", avatar='🌿'):
91
+ st.markdown(response)
92
+
93
  # Play the generated speech
94
+ display(Audio(speech_file, autoplay=True))
95
 
96
  # Add assistant response to chat history
97
  st.session_state.messages.append({"role": "assistant", "content": response})
 
113
  st.markdown(response)
114
 
115
  # Play the generated speech
116
+ display(Audio(speech_file, autoplay=True))
117
 
118
  # Add assistant response to chat history
119
  st.session_state.messages.append({"role": "assistant", "content": response})