Spaces:
Sleeping
Sleeping
Commit
·
fab312d
1
Parent(s):
e16f390
only prints text now (only in english
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ model = whisper.load_model("small")
|
|
7 |
|
8 |
|
9 |
|
10 |
-
def predict(audio, mic_audio=None):
|
11 |
# audio = tuple (sample_rate, frames) or (sample_rate, (frames, channels))
|
12 |
if mic_audio is not None:
|
13 |
input_audio = mic_audio
|
@@ -21,13 +21,13 @@ def predict(audio, mic_audio=None):
|
|
21 |
|
22 |
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
23 |
|
24 |
-
|
25 |
|
26 |
options = whisper.DecodingOptions(fp16 = False)
|
27 |
result = whisper.decode(model, mel, options)
|
28 |
|
29 |
print(result.text)
|
30 |
-
return result.text
|
31 |
|
32 |
|
33 |
|
|
|
7 |
|
8 |
|
9 |
|
10 |
+
def predict(audio, mic_audio=None, target_language):
|
11 |
# audio = tuple (sample_rate, frames) or (sample_rate, (frames, channels))
|
12 |
if mic_audio is not None:
|
13 |
input_audio = mic_audio
|
|
|
21 |
|
22 |
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
23 |
|
24 |
+
language, probs = model.detect_language(mel)
|
25 |
|
26 |
options = whisper.DecodingOptions(fp16 = False)
|
27 |
result = whisper.decode(model, mel, options)
|
28 |
|
29 |
print(result.text)
|
30 |
+
return result.text, result.language
|
31 |
|
32 |
|
33 |
|