Spaces:
Sleeping
Sleeping
N.Achyuth Reddy commited on
Commit ·
a8498c0
1
Parent(s): cffc6f1
Update app.py
Browse files
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 |
-
|
| 6 |
|
| 7 |
# Constants
|
| 8 |
TITLE = "AgriTure"
|
|
@@ -86,12 +86,8 @@ if wav_audio_data is not None:
|
|
| 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 |
-
|
| 95 |
|
| 96 |
# Add assistant response to chat history
|
| 97 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
@@ -113,7 +109,7 @@ if prompt := textinput:
|
|
| 113 |
st.markdown(response)
|
| 114 |
|
| 115 |
# Play the generated speech
|
| 116 |
-
|
| 117 |
|
| 118 |
# Add assistant response to chat history
|
| 119 |
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 |
+
import os
|
| 6 |
|
| 7 |
# Constants
|
| 8 |
TITLE = "AgriTure"
|
|
|
|
| 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 |
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})
|