huedaya commited on
Commit
b03e1fb
·
1 Parent(s): 9e89ce1
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -51,12 +51,23 @@ def runApi():
51
  }), 400
52
 
53
  # arr = np.asarray(bytearray(response.content), dtype=np.uint8)
54
- result = model.transcribe("audio.mp3")
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  return jsonify({
57
  "audio_url": audio_url,
58
  "model": model,
59
- "result": result,
60
  })
61
 
62
  if __name__ == "__main__":
 
51
  }), 400
52
 
53
  # arr = np.asarray(bytearray(response.content), dtype=np.uint8)
54
+ # result = model.transcribe("audio.mp3")
55
+ audio = "audio.mp3"
56
+
57
+ audio = whisper.load_audio(audio)
58
+ audio = whisper.pad_or_trim(audio)
59
+
60
+ mel = whisper.log_mel_spectrogram(audio).to(model.device)
61
+
62
+ _, probs = model.detect_language(mel)
63
+
64
+ options = whisper.DecodingOptions(fp16 = False)
65
+ result = whisper.decode(model, mel, options)
66
 
67
  return jsonify({
68
  "audio_url": audio_url,
69
  "model": model,
70
+ "result": result.text,
71
  })
72
 
73
  if __name__ == "__main__":