ziyadsuper2017 commited on
Commit
72e6706
·
verified ·
1 Parent(s): 4af010e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -153,7 +153,6 @@ def send_message(audio_data=None):
153
  except Exception as e:
154
  st.error(f"An error occurred: {e}")
155
 
156
- st.session_state.user_input = ''
157
  st.session_state.uploaded_files = []
158
  st.session_state.file_uploader_key = str(uuid.uuid4())
159
 
@@ -166,7 +165,8 @@ with col1:
166
  user_input = st.text_area(
167
  "Enter your message:",
168
  value="",
169
- key="user_input"
 
170
  )
171
  with col2:
172
  send_button = st.button(
@@ -214,12 +214,12 @@ async def run_webrtc():
214
  audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
215
  audio_data = [frame.to_ndarray() for frame in audio_frames]
216
  st.session_state.audio_data = convert_frames_to_wav(audio_data)
 
 
 
217
  else:
218
  st.session_state.is_recording = False
219
 
220
- if st.button("Send Recording"):
221
- send_message(audio_data=st.session_state.audio_data)
222
-
223
  # --- Other Buttons ---
224
  st.button("Clear Conversation", on_click=clear_conversation)
225
 
@@ -236,7 +236,7 @@ st.markdown(
236
  }
237
  });
238
  </script>
239
- """,
240
  unsafe_allow_html=True
241
  )
242
 
 
153
  except Exception as e:
154
  st.error(f"An error occurred: {e}")
155
 
 
156
  st.session_state.uploaded_files = []
157
  st.session_state.file_uploader_key = str(uuid.uuid4())
158
 
 
165
  user_input = st.text_area(
166
  "Enter your message:",
167
  value="",
168
+ key="user_input",
169
+ on_change=lambda: setattr(st.session_state, 'user_input', '')
170
  )
171
  with col2:
172
  send_button = st.button(
 
214
  audio_frames = webrtc_ctx.audio_receiver.get_frames(timeout=None)
215
  audio_data = [frame.to_ndarray() for frame in audio_frames]
216
  st.session_state.audio_data = convert_frames_to_wav(audio_data)
217
+
218
+ if st.button("Send Recording"):
219
+ send_message(audio_data=st.session_state.audio_data)
220
  else:
221
  st.session_state.is_recording = False
222
 
 
 
 
223
  # --- Other Buttons ---
224
  st.button("Clear Conversation", on_click=clear_conversation)
225
 
 
236
  }
237
  });
238
  </script>
239
+ """,
240
  unsafe_allow_html=True
241
  )
242