ricklon commited on
Commit
244b56f
·
1 Parent(s): 20427c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,14 +4,14 @@ import tempfile
4
 
5
  # Function to transcribe audio and detect language
6
  def transcribe_and_detect_language(audio_file):
7
- model = whisper.load_model("base")
8
 
9
- # Load audio and pad/trim it to fit 30 seconds
10
  audio = whisper.load_audio(audio_file)
11
  audio = whisper.pad_or_trim(audio)
12
 
13
- # Make log-Mel spectrogram and move to the same device as the model
14
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
15
 
16
  # Detect the spoken language
17
  _, probs = model.detect_language(mel)
 
4
 
5
  # Function to transcribe audio and detect language
6
  def transcribe_and_detect_language(audio_file):
7
+ model = whisper.load_model("base").to("cpu").float() # Ensure model is in full precision
8
 
9
+ # Load and process audio
10
  audio = whisper.load_audio(audio_file)
11
  audio = whisper.pad_or_trim(audio)
12
 
13
+ # Convert to log-Mel spectrogram in full precision
14
+ mel = whisper.log_mel_spectrogram(audio).to(model.device).float() # Convert to float32
15
 
16
  # Detect the spoken language
17
  _, probs = model.detect_language(mel)