yadongxie commited on
Commit
28391f7
1 Parent(s): d00dc38

fix: remove auto restart

Browse files
Files changed (1) hide show
  1. app.py +1 -11
app.py CHANGED
@@ -155,13 +155,6 @@ def response(state: AppState):
155
  state.pause_detected = False
156
 
157
 
158
- def start_recording_user(state: AppState):
159
- if not state.stopped:
160
- return gr.Audio(recording=True)
161
- else:
162
- return gr.Audio(recording=False)
163
-
164
-
165
  def set_api_key(api_key, state):
166
  if not api_key:
167
  raise gr.Error("Please enter a valid API key.")
@@ -223,15 +216,12 @@ with gr.Blocks() as demo:
223
  # Update the chatbot with the final conversation
224
  respond.then(lambda s: s.conversation, [state], [chatbot])
225
 
226
- # Automatically restart recording after the assistant's response
227
- restart = output_audio.stop(start_recording_user, [state], [input_audio])
228
-
229
  # Add a "Stop Conversation" button
230
  cancel.click(
231
  lambda: (AppState(stopped=True), gr.Audio(recording=False)),
232
  None,
233
  [state, input_audio],
234
- cancels=[respond, restart],
235
  )
236
 
237
  demo.launch()
 
155
  state.pause_detected = False
156
 
157
 
 
 
 
 
 
 
 
158
  def set_api_key(api_key, state):
159
  if not api_key:
160
  raise gr.Error("Please enter a valid API key.")
 
216
  # Update the chatbot with the final conversation
217
  respond.then(lambda s: s.conversation, [state], [chatbot])
218
 
 
 
 
219
  # Add a "Stop Conversation" button
220
  cancel.click(
221
  lambda: (AppState(stopped=True), gr.Audio(recording=False)),
222
  None,
223
  [state, input_audio],
224
+ cancels=[respond],
225
  )
226
 
227
  demo.launch()