DMMP commited on
Commit
7069760
·
verified ·
1 Parent(s): df48a43

minor change in transcribe audio

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -114,18 +114,19 @@ def transcribe_audio(audio_path: str) -> str:
114
  Returns:
115
  str : Transcription of the audio.
116
  """
117
- client = openai.Client(api_key=os.getenv("OPENAI_API_KEY"))
118
- with open(audio_path, "rb") as audio: # to modify path because it is arriving from gradio
119
- transcript = client.audio.transcriptions.create(
120
- file=audio,
121
- model="whisper-1",
122
- response_format="text",
123
- )
124
- print(transcript)
125
  try:
 
 
 
 
 
 
 
 
126
  return transcript
127
  except Exception as e:
128
  print(f"Error transcribing audio: {e}")
 
129
 
130
  @tool
131
  def generate_image(prompt: str, neg_prompt: str) -> Image.Image:
 
114
  Returns:
115
  str : Transcription of the audio.
116
  """
 
 
 
 
 
 
 
 
117
  try:
118
+ client = openai.Client(api_key=os.getenv("OPENAI_API_KEY"))
119
+ with open(audio_path, "rb") as audio: # to modify path because it is arriving from gradio
120
+ transcript = client.audio.transcriptions.create(
121
+ file=audio,
122
+ model="whisper-1",
123
+ response_format="text",
124
+ )
125
+ print(transcript)
126
  return transcript
127
  except Exception as e:
128
  print(f"Error transcribing audio: {e}")
129
+ return ""
130
 
131
  @tool
132
  def generate_image(prompt: str, neg_prompt: str) -> Image.Image: