SaileshSivan commited on
Commit
aeddbec
·
1 Parent(s): c86e6b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -17,7 +17,7 @@ def get_chatmodel_response(question):
17
  st.session_state['flowmessages'].append(HumanMessage(content=question))
18
  answer = chat(st.session_state['flowmessages'])
19
  st.session_state['flowmessages'].append(AIMessage(content=answer.content))
20
- return answer.content
21
  except Exception as e:
22
  print(f"Error: {e}")
23
  if "Rate limit" in str(e):
@@ -69,6 +69,7 @@ with st.form(key='my_form',clear_on_submit=True):
69
  )
70
 
71
  input_question = st.text_input("Type here.", key="input")
 
72
 
73
  submit = st.form_submit_button("Submit")
74
 
@@ -91,11 +92,12 @@ if submit:
91
  input=response
92
  )
93
  # Display audio on the webpage
94
- st.audio(response_audio['url'], format='audio/mp3')
95
 
96
  # Add a download button for the audio
97
- audio_data = base64.b64decode(response_audio['url'].split(',')[1])
98
- st.markdown(f"### [Download Audio](data:audio/mp3;base64,{base64.b64encode(audio_data).decode()})", unsafe_allow_html=True)
 
99
 
100
  if response is not None:
101
 
 
17
  st.session_state['flowmessages'].append(HumanMessage(content=question))
18
  answer = chat(st.session_state['flowmessages'])
19
  st.session_state['flowmessages'].append(AIMessage(content=answer.content))
20
+ return answer.content, answer.audio
21
  except Exception as e:
22
  print(f"Error: {e}")
23
  if "Rate limit" in str(e):
 
69
  )
70
 
71
  input_question = st.text_input("Type here.", key="input")
72
+ response_text, response_audio = get_chatmodel_response(input_text)
73
 
74
  submit = st.form_submit_button("Submit")
75
 
 
92
  input=response
93
  )
94
  # Display audio on the webpage
95
+ st.audio(response_audio, format='audio/mp3')
96
 
97
  # Add a download button for the audio
98
+ # Add a download button for the audio
99
+ audio_data = base64.b64decode(response_audio.split(',')[1])
100
+ st.markdown(f"### [Download Audio](data:audio/mp3;base64,{base64.b64encode(audio_data).decode()})", unsafe_allow_html=True)
101
 
102
  if response is not None:
103