IAMTFRMZA commited on
Commit
3bfe4cd
·
verified ·
1 Parent(s): 1d7fcfa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -126,10 +126,13 @@ def handle_chat(user_input, history, thread_id, image_url):
126
  return f"❌ {e}", history, thread_id, image_url
127
 
128
  # ============ Auto-Send Voice Toggle ============
129
- def maybe_send_transcript(transcript, history, thread_id, image_url, voice_only_enabled):
130
  if voice_only_enabled and transcript.strip():
 
 
 
131
  return handle_chat(transcript, history, thread_id, image_url)
132
- return transcript, history, thread_id, image_url # Keep transcript for manual sending
133
 
134
  # ============ Gradio UI ============
135
  with gr.Blocks(theme=gr.themes.Soft()) as app:
@@ -179,7 +182,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
179
  # Auto-send voice transcript if Voice-Only Mode is enabled
180
  voice_input.change(
181
  fn=maybe_send_transcript,
182
- inputs=[voice_transcript, chat_state, thread_state, image_state, voice_only_state],
183
  outputs=[user_prompt, chat, thread_state, image_state]
184
  )
185
 
 
126
  return f"❌ {e}", history, thread_id, image_url
127
 
128
  # ============ Auto-Send Voice Toggle ============
129
+ def maybe_send_transcript(transcript, history, thread_id, image_url, voice_only_enabled, client_id):
130
  if voice_only_enabled and transcript.strip():
131
+ # Clear transcript after sending
132
+ if client_id in connections:
133
+ connections[client_id].transcript = ""
134
  return handle_chat(transcript, history, thread_id, image_url)
135
+ return transcript, history, thread_id, image_url
136
 
137
  # ============ Gradio UI ============
138
  with gr.Blocks(theme=gr.themes.Soft()) as app:
 
182
  # Auto-send voice transcript if Voice-Only Mode is enabled
183
  voice_input.change(
184
  fn=maybe_send_transcript,
185
+ inputs=[voice_transcript, chat_state, thread_state, image_state, voice_only_state, client_id],
186
  outputs=[user_prompt, chat, thread_state, image_state]
187
  )
188