Core23 commited on
Commit
3a022d6
1 Parent(s): f136dfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -2,6 +2,8 @@ import os
2
  import openai
3
  import gradio as gr
4
  from transformers import pipeline
 
 
5
 
6
  openai.api_key = os.getenv("OPENAI_API_KEY")
7
  pipe = pipeline(model="Ussen/whisper-medium-swc-drc-kat-1")
@@ -120,8 +122,11 @@ def inference(text):
120
  voice="alloy",
121
  text=text
122
  )
123
- audio_url = response['url']
124
- return audio_url
 
 
 
125
 
126
  def process_audio_and_respond(audio):
127
  text = transcribe(audio)
 
2
  import openai
3
  import gradio as gr
4
  from transformers import pipeline
5
+ import tempfile
6
+ import requests
7
 
8
  openai.api_key = os.getenv("OPENAI_API_KEY")
9
  pipe = pipeline(model="Ussen/whisper-medium-swc-drc-kat-1")
 
122
  voice="alloy",
123
  text=text
124
  )
125
+ if 'url' in response:
126
+ audio_url = response['url']
127
+ return audio_url
128
+ else:
129
+ raise Exception("An error occurred: OpenAI did not return an 'url' for the audio file.")
130
 
131
  def process_audio_and_respond(audio):
132
  text = transcribe(audio)