lyimo commited on
Commit
94cd149
·
1 Parent(s): cd5171e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -4,7 +4,7 @@ import openai
4
  import gradio as gr
5
  import requests
6
  from gtts import gTTS
7
- import asyncio # Import asyncio for the asynchronous functionality
8
 
9
  openai.api_key = os.getenv("OPENAI_API_KEY")
10
 
@@ -50,13 +50,6 @@ def inference(text):
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)
@@ -74,4 +67,5 @@ demo = gr.Interface(
74
  allow_flagging=False,
75
  live=True,
76
  )
77
- asyncio.run(demo.launch())
 
 
4
  import gradio as gr
5
  import requests
6
  from gtts import gTTS
7
+
8
 
9
  openai.api_key = os.getenv("OPENAI_API_KEY")
10
 
 
50
  tts.save(output_file)
51
  return output_file
52
 
 
 
 
 
 
 
 
53
  def process_audio_and_respond(audio):
54
  text = transcribe(audio)
55
  response_text = generate_response(text)
 
67
  allow_flagging=False,
68
  live=True,
69
  )
70
+
71
+ demo.launch()