Spaces:
Runtime error
Runtime error
save
Browse files
app.py
CHANGED
@@ -41,25 +41,22 @@ def runApi():
|
|
41 |
|
42 |
audio = "audio.mp3"
|
43 |
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
# result = pipe(audio.copy())["text"]
|
55 |
-
result = model.transcribe(audio)
|
56 |
|
57 |
end_time = time.time()
|
58 |
total_time = end_time - start_time
|
59 |
|
60 |
return jsonify({
|
61 |
"audio_url": audio_url,
|
62 |
-
"result": result
|
63 |
"exec_time_sec": total_time
|
64 |
})
|
65 |
|
|
|
41 |
|
42 |
audio = "audio.mp3"
|
43 |
|
44 |
+
audio = whisper.load_audio(audio)
|
45 |
+
audio = whisper.pad_or_trim(audio)
|
46 |
|
47 |
+
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
48 |
|
49 |
+
_, probs = model.detect_language(mel)
|
50 |
|
51 |
+
options = whisper.DecodingOptions(fp16 = False)
|
52 |
+
result = whisper.decode(model, mel, options)
|
|
|
|
|
|
|
53 |
|
54 |
end_time = time.time()
|
55 |
total_time = end_time - start_time
|
56 |
|
57 |
return jsonify({
|
58 |
"audio_url": audio_url,
|
59 |
+
"result": result.text,
|
60 |
"exec_time_sec": total_time
|
61 |
})
|
62 |
|