Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,23 +19,10 @@ def get_completion(prompt, model='gpt-3.5-turbo'):
|
|
| 19 |
return response.choices[0].message['content']
|
| 20 |
|
| 21 |
def transcribe(audio):
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
# load audio and pad/trim it to fit 30 seconds
|
| 25 |
-
audio = whisper.load_audio(audio_file)
|
| 26 |
-
audio = whisper.pad_or_trim(audio)
|
| 27 |
-
|
| 28 |
-
# make log-Mel spectrogram and move to the same device as the model
|
| 29 |
-
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
| 30 |
-
|
| 31 |
-
# detect the spoken language
|
| 32 |
-
_, probs = model.detect_language(mel)
|
| 33 |
-
print(f"Detected language: {max(probs, key=probs.get)}")
|
| 34 |
-
|
| 35 |
-
# decode the audio
|
| 36 |
-
options = whisper.DecodingOptions(fp16 = False)
|
| 37 |
-
result = whisper.decode(model, mel, options)
|
| 38 |
return result.text
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
|
|
|
|
| 19 |
return response.choices[0].message['content']
|
| 20 |
|
| 21 |
def transcribe(audio):
|
| 22 |
+
model = whisper.load_model("medium")
|
| 23 |
+
result = model.transcribe(audio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
return result.text
|
| 25 |
+
|
| 26 |
|
| 27 |
|
| 28 |
|