ndurner commited on
Commit
f131994
·
1 Parent(s): cc224b9

fix Whisper

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -155,20 +155,29 @@ def bot(message, history, oai_key, system_prompt, seed, temperature, max_tokens,
155
  for human, assi in history:
156
  if human is not None:
157
  if type(human) is tuple:
158
- audio_fn = human[0]
159
- with open(audio_fn, "rb") as f:
160
- transcription = client.audio.transcriptions.create(
161
- model="whisper-1",
162
- prompt=whisper_prompt,
163
- file=f,
164
- response_format="text"
165
- )
166
- whisper_prompt += f"\n{transcription}"
167
- result += f"\n``` transcript {audio_fn}\n {transcription}\n```"
168
  else:
169
  whisper_prompt += f"\n{human}"
170
  if assi is not None:
171
  whisper_prompt += f"\n{assi}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  elif model == "dall-e-3":
173
  response = client.images.generate(
174
  model=model,
 
155
  for human, assi in history:
156
  if human is not None:
157
  if type(human) is tuple:
158
+ pass
 
 
 
 
 
 
 
 
 
159
  else:
160
  whisper_prompt += f"\n{human}"
161
  if assi is not None:
162
  whisper_prompt += f"\n{assi}"
163
+
164
+ if message.text:
165
+ whisper_prompt += message.text
166
+ if message.files:
167
+ for file in message.files:
168
+ audio_fn = os.path.basename(file.path)
169
+ with open(file.path, "rb") as f:
170
+ transcription = client.audio.transcriptions.create(
171
+ model="whisper-1",
172
+ prompt=whisper_prompt,
173
+ file=f,
174
+ response_format="text"
175
+ )
176
+ whisper_prompt += f"\n{transcription}"
177
+ result += f"\n``` transcript {audio_fn}\n {transcription}\n```"
178
+
179
+ yield result
180
+
181
  elif model == "dall-e-3":
182
  response = client.images.generate(
183
  model=model,