Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -50,7 +50,7 @@ from scipy.io import wavfile
|
|
50 |
import subprocess
|
51 |
|
52 |
import whisper
|
53 |
-
|
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
|
170 |
-
mel = whisper.log_mel_spectrogram(audio).to(
|
171 |
|
172 |
# detect the spoken language
|
173 |
-
_, probs =
|
174 |
print(f"Detected language: {max(probs, key=probs.get)}")
|
175 |
|
176 |
# decode the audio
|
177 |
options = whisper.DecodingOptions()
|
178 |
-
result = whisper.decode(
|
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":
|