lyimo commited on
Commit
d62dd0b
·
1 Parent(s): cffcfb8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -50,20 +50,23 @@ def inference(text):
50
  tts.save(output_file)
51
  return output_file
52
 
53
- # Here is the new function
54
  async def process_audio_and_respond(audio):
55
  text = await asyncio.to_thread(transcribe, audio)
56
  response_text = await asyncio.to_thread(generate_response, text)
57
  output_file = await asyncio.to_thread(inference, response_text)
58
  return response_text, output_file
59
 
 
 
 
 
 
 
60
  demo = gr.Interface(
61
  process_audio_and_respond,
62
  gr.inputs.Audio(source="microphone", type="filepath", label="Bonyeza kitufe cha kurekodi na uliza swali lako"),
63
- [gr.outputs.TextOops, my previous message got cut off. Here's the rest of the code:
64
-
65
-
66
- Textbox(label="Jibu (kwa njia ya maandishi)"), gr.outputs.Audio(type="filepath", label="Jibu kwa njia ya sauti (Bofya kusikiliza Jibu)")],
67
  title="Mtaalamu wa Viazi Lishe",
68
  description="Uliza Mtaalamu wetu swali lolote Kuhusu viazi Lishe",
69
  theme="compact",
@@ -71,6 +74,4 @@ demo = gr.Interface(
71
  allow_flagging=False,
72
  live=True,
73
  )
74
-
75
- # Use asyncio.run to start the Gradio interface
76
  asyncio.run(demo.launch())
 
50
  tts.save(output_file)
51
  return output_file
52
 
53
+
54
  async def process_audio_and_respond(audio):
55
  text = await asyncio.to_thread(transcribe, audio)
56
  response_text = await asyncio.to_thread(generate_response, text)
57
  output_file = await asyncio.to_thread(inference, response_text)
58
  return response_text, output_file
59
 
60
+ def process_audio_and_respond(audio):
61
+ text = transcribe(audio)
62
+ response_text = generate_response(text)
63
+ output_file = inference(response_text)
64
+ return response_text, output_file
65
+
66
  demo = gr.Interface(
67
  process_audio_and_respond,
68
  gr.inputs.Audio(source="microphone", type="filepath", label="Bonyeza kitufe cha kurekodi na uliza swali lako"),
69
+ [gr.outputs.Textbox(label="Jibu (kwa njia ya maandishi)"), gr.outputs.Audio(type="filepath", label="Jibu kwa njia ya sauti (Bofya kusikiliza Jibu)")],
 
 
 
70
  title="Mtaalamu wa Viazi Lishe",
71
  description="Uliza Mtaalamu wetu swali lolote Kuhusu viazi Lishe",
72
  theme="compact",
 
74
  allow_flagging=False,
75
  live=True,
76
  )
 
 
77
  asyncio.run(demo.launch())