Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ import torchaudio
|
|
32 |
from speechbrain.pretrained import SpectralMaskEnhancement
|
33 |
|
34 |
import whisper
|
35 |
-
|
36 |
|
37 |
import openai
|
38 |
|
@@ -133,15 +133,15 @@ def greet(Text2, audio, Voicetoclone,VoiceMicrophone):
|
|
133 |
audio = whisper.pad_or_trim(audio)
|
134 |
|
135 |
# make log-Mel spectrogram and move to the same device as the model
|
136 |
-
mel = whisper.log_mel_spectrogram(audio).to(
|
137 |
|
138 |
# detect the spoken language
|
139 |
-
_, probs =
|
140 |
print(f"Detected language: {max(probs, key=probs.get)}")
|
141 |
|
142 |
# decode the audio
|
143 |
options = whisper.DecodingOptions()
|
144 |
-
result = whisper.decode(
|
145 |
res.append(result.text)
|
146 |
|
147 |
messages = mes
|
|
|
32 |
from speechbrain.pretrained import SpectralMaskEnhancement
|
33 |
|
34 |
import whisper
|
35 |
+
model1 = whisper.load_model("tiny")
|
36 |
|
37 |
import openai
|
38 |
|
|
|
133 |
audio = whisper.pad_or_trim(audio)
|
134 |
|
135 |
# make log-Mel spectrogram and move to the same device as the model
|
136 |
+
mel = whisper.log_mel_spectrogram(audio).to(model1.device)
|
137 |
|
138 |
# detect the spoken language
|
139 |
+
_, probs = model1.detect_language(mel)
|
140 |
print(f"Detected language: {max(probs, key=probs.get)}")
|
141 |
|
142 |
# decode the audio
|
143 |
options = whisper.DecodingOptions()
|
144 |
+
result = whisper.decode(model1, mel, options)
|
145 |
res.append(result.text)
|
146 |
|
147 |
messages = mes
|