Kevin676 commited on
Commit
361cc97
·
1 Parent(s): 6de4e36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -50,7 +50,7 @@ from scipy.io import wavfile
50
  import subprocess
51
 
52
  import whisper
53
- model = whisper.load_model("base")
54
  os.system('pip install voicefixer --upgrade')
55
  from voicefixer import VoiceFixer
56
  voicefixer = VoiceFixer()
@@ -166,16 +166,16 @@ def voice_conversion(apikey, ta, audio, choice1):
166
  audio = whisper.load_audio(audio)
167
  audio = whisper.pad_or_trim(audio)
168
 
169
- # make log-Mel spectrogram and move to the same device as the model
170
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
171
 
172
  # detect the spoken language
173
- _, probs = model.detect_language(mel)
174
  print(f"Detected language: {max(probs, key=probs.get)}")
175
 
176
  # decode the audio
177
  options = whisper.DecodingOptions()
178
- result = whisper.decode(model, mel, options)
179
  res.append(result.text)
180
 
181
  if choice1 == "TOEFL":
 
50
  import subprocess
51
 
52
  import whisper
53
+ model1 = whisper.load_model("base")
54
  os.system('pip install voicefixer --upgrade')
55
  from voicefixer import VoiceFixer
56
  voicefixer = VoiceFixer()
 
166
  audio = whisper.load_audio(audio)
167
  audio = whisper.pad_or_trim(audio)
168
 
169
+ # make log-Mel spectrogram and move to the same device as the model1
170
+ mel = whisper.log_mel_spectrogram(audio).to(model1.device)
171
 
172
  # detect the spoken language
173
+ _, probs = model1.detect_language(mel)
174
  print(f"Detected language: {max(probs, key=probs.get)}")
175
 
176
  # decode the audio
177
  options = whisper.DecodingOptions()
178
+ result = whisper.decode(model1, mel, options)
179
  res.append(result.text)
180
 
181
  if choice1 == "TOEFL":