Update app.py
Browse files
app.py
CHANGED
@@ -176,8 +176,9 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
176 |
|
177 |
|
178 |
def generate_audio():
|
179 |
-
|
180 |
-
|
|
|
181 |
|
182 |
for item in output:
|
183 |
full_response += item
|
@@ -187,8 +188,8 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
187 |
|
188 |
if "reference" not in st.session_state:
|
189 |
st.session_state.reference = False
|
190 |
-
|
191 |
-
|
192 |
|
193 |
with st.sidebar:
|
194 |
choice = st.radio("References and TTS",["Reference" , 'TTS'])
|
@@ -201,7 +202,7 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
201 |
if choice == 'TTS':
|
202 |
generate_audio()
|
203 |
st.session_state['audio'] = '/home/user/app/audio/audio.mp3'
|
204 |
-
st.audio(st.session_state['audio'])
|
205 |
|
206 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
207 |
|
|
|
176 |
|
177 |
|
178 |
def generate_audio():
|
179 |
+
with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
|
180 |
+
tts = gTTS(result['result'], lang='en', tld='co.in')
|
181 |
+
tts.write_to_fp(sound_file)
|
182 |
|
183 |
for item in output:
|
184 |
full_response += item
|
|
|
188 |
|
189 |
if "reference" not in st.session_state:
|
190 |
st.session_state.reference = False
|
191 |
+
if "audio" not in st.session_state:
|
192 |
+
st.session_state.audio = False
|
193 |
|
194 |
with st.sidebar:
|
195 |
choice = st.radio("References and TTS",["Reference" , 'TTS'])
|
|
|
202 |
if choice == 'TTS':
|
203 |
generate_audio()
|
204 |
st.session_state['audio'] = '/home/user/app/audio/audio.mp3'
|
205 |
+
st.audio(st.session_state['audio'], format='audio/mp3')
|
206 |
|
207 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
208 |
|