gstaff commited on
Commit
45e1616
β€’
1 Parent(s): aa07a0a

Move clear of audio to generate_text step.

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -161,12 +161,12 @@ def generate_text(code, prompt):
161
  new_code = match.group(1)
162
  print(new_code)
163
  # TODO: error handling here
164
- return assistant_reply, new_code
165
 
166
 
167
  def transcribe(audio):
168
  result = whisper_pipe(audio)
169
- return result["text"], None
170
 
171
 
172
  def copy_notify(code):
@@ -194,7 +194,7 @@ with gr.Blocks() as demo:
194
  update_btn = gr.Button("Update App", variant="primary")
195
  update_btn.click(None, inputs=code_area, outputs=None, _js=update_iframe_js)
196
  in_prompt.submit(generate_text, [code_area, in_prompt], [out_text, code_area]).then(None, inputs=code_area, outputs=None, _js=update_iframe_js)
197
- in_audio.stop_recording(transcribe, [in_audio], [in_prompt, in_audio]).then(generate_text, [code_area, in_prompt], [out_text, code_area]).then(None, inputs=code_area, outputs=None, _js=update_iframe_js)
198
  with gr.Row():
199
  with gr.Column():
200
  gr.Markdown("## 3. Export your app to share!")
 
161
  new_code = match.group(1)
162
  print(new_code)
163
  # TODO: error handling here
164
+ return assistant_reply, new_code, None
165
 
166
 
167
  def transcribe(audio):
168
  result = whisper_pipe(audio)
169
+ return result["text"]
170
 
171
 
172
  def copy_notify(code):
 
194
  update_btn = gr.Button("Update App", variant="primary")
195
  update_btn.click(None, inputs=code_area, outputs=None, _js=update_iframe_js)
196
  in_prompt.submit(generate_text, [code_area, in_prompt], [out_text, code_area]).then(None, inputs=code_area, outputs=None, _js=update_iframe_js)
197
+ in_audio.stop_recording(transcribe, [in_audio], [in_prompt]).then(generate_text, [code_area, in_prompt, in_audio], [out_text, code_area]).then(None, inputs=code_area, outputs=None, _js=update_iframe_js)
198
  with gr.Row():
199
  with gr.Column():
200
  gr.Markdown("## 3. Export your app to share!")