freddyaboulton HF Staff commited on
Commit
5075bfa
·
1 Parent(s): 4c628f2
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -65,8 +65,8 @@ frame_rate = model.audio_encoder.config.frame_rate
65
 
66
 
67
  def generate_response(audio):
68
- yield None, gr.Textbox(visible=True)
69
- question = client.automatic_speech_recognition(audio)
70
 
71
  messages = [{"role": "sytem", "content": ("You are a magic 8 ball."
72
  "Someone will present to you a situation or question and your job "
@@ -76,7 +76,7 @@ def generate_response(audio):
76
 
77
  response = client.chat_completion(messages, max_tokens=128, seed=random.randint(1, 5000))
78
  response = response.choices[0].message.content
79
- yield response, gr.Textbox(visible=True)
80
 
81
 
82
  @spaces.GPU
@@ -121,7 +121,7 @@ with gr.Blocks() as block:
121
  )
122
  with gr.Group():
123
  with gr.Row():
124
- audio_out = gr.Audio(visible=False, streaming=True)
125
  answer = gr.Textbox(visible=False, label="Answer")
126
  state = gr.State()
127
 
 
65
 
66
 
67
  def generate_response(audio):
68
+ gr.Info("Transcribing Audio", duration=5)
69
+ question = client.automatic_speech_recognition(audio).text
70
 
71
  messages = [{"role": "sytem", "content": ("You are a magic 8 ball."
72
  "Someone will present to you a situation or question and your job "
 
76
 
77
  response = client.chat_completion(messages, max_tokens=128, seed=random.randint(1, 5000))
78
  response = response.choices[0].message.content
79
+ return response, gr.Textbox(visible=True)
80
 
81
 
82
  @spaces.GPU
 
121
  )
122
  with gr.Group():
123
  with gr.Row():
124
+ audio_out = gr.Audio(visible=False, streaming=True, autoplay=True)
125
  answer = gr.Textbox(visible=False, label="Answer")
126
  state = gr.State()
127