Update app.py
Browse files
app.py
CHANGED
@@ -172,14 +172,14 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
172 |
#st.session_state.reference = True
|
173 |
|
174 |
st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
|
|
|
|
|
175 |
|
176 |
def generate_audio():
|
177 |
sound_file = BytesIO()
|
178 |
tts = gTTS(result['result'], lang='en')
|
179 |
tts.write_to_fp(sound_file)
|
180 |
-
|
181 |
-
st.session_state.audio = True
|
182 |
-
|
183 |
|
184 |
for item in output:
|
185 |
full_response += item
|
@@ -193,17 +193,18 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
193 |
# st.session_state.audio = False
|
194 |
|
195 |
with st.sidebar:
|
196 |
-
choice = st.radio("References and TTS",["Reference"])
|
197 |
|
198 |
if choice == 'Reference':
|
199 |
generate_pdf()
|
200 |
st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
|
201 |
st.image(st.session_state['reference'])
|
202 |
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
|
|
|
208 |
|
209 |
|
|
|
172 |
#st.session_state.reference = True
|
173 |
|
174 |
st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
|
175 |
+
st.session_state['audio'] = ''
|
176 |
+
|
177 |
|
178 |
def generate_audio():
|
179 |
sound_file = BytesIO()
|
180 |
tts = gTTS(result['result'], lang='en')
|
181 |
tts.write_to_fp(sound_file)
|
182 |
+
return sound_file
|
|
|
|
|
183 |
|
184 |
for item in output:
|
185 |
full_response += item
|
|
|
193 |
# st.session_state.audio = False
|
194 |
|
195 |
with st.sidebar:
|
196 |
+
choice = st.radio("References and TTS",["Reference" , 'TTS'])
|
197 |
|
198 |
if choice == 'Reference':
|
199 |
generate_pdf()
|
200 |
st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
|
201 |
st.image(st.session_state['reference'])
|
202 |
|
203 |
+
if choice == 'TTS':
|
204 |
+
x=generate_audio()
|
205 |
+
st.session_state['audio'] = x
|
206 |
+
st.image(st.session_state['audio'])
|
207 |
|
208 |
+
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
209 |
|
210 |
|