ugaray96 commited on
Commit
1bdd33b
1 Parent(s): 710a34d

Improves audio to text by using the transcribe function

Browse files
Files changed (1) hide show
  1. core/audio.py +2 -5
core/audio.py CHANGED
@@ -16,10 +16,7 @@ def audio_to_text(model, audio_file):
16
  audio.export("audio_tmp")
17
  try:
18
  audio = whisper.load_audio("audio_tmp")
19
- audio = whisper.pad_or_trim(audio)
20
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
21
- options = whisper.DecodingOptions()
22
- result = whisper.decode(model, mel, options)
23
  finally:
24
  os.remove("audio_tmp")
25
- return result.text
 
16
  audio.export("audio_tmp")
17
  try:
18
  audio = whisper.load_audio("audio_tmp")
19
+ result = whisper.transcribe(model=model, audio=audio, verbose=True)
 
 
 
20
  finally:
21
  os.remove("audio_tmp")
22
+ return result["text"]