Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ from datetime import datetime
|
|
11 |
|
12 |
import assets
|
13 |
|
14 |
-
def sendToWhisper(audio_record, audio_upload,
|
15 |
results = []
|
16 |
|
17 |
audio = None
|
@@ -24,25 +24,14 @@ def sendToWhisper(audio_record, audio_upload, task, models_selected, language_to
|
|
24 |
|
25 |
audio = whisper.load_audio(audio)
|
26 |
audio = whisper.pad_or_trim(audio)
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
language = ""
|
36 |
-
prob = 0
|
37 |
-
if model_name in assets.lang_detect:
|
38 |
-
_, probs = model.detect_language(mel)
|
39 |
-
language = max(probs, key=probs.get)
|
40 |
-
prob = probs[language]
|
41 |
-
else:
|
42 |
-
language="en"
|
43 |
-
options = whisper.DecodingOptions(fp16 = False, without_timestamps=without_timestamps, task=task, language="en")
|
44 |
-
output_text = whisper.decode(model, mel, options)
|
45 |
-
results.append([model_name, output_text.text, language, str(prob), str((datetime.now() - start).total_seconds())])
|
46 |
return results
|
47 |
|
48 |
avail_models = whisper.available_models()
|
@@ -77,6 +66,7 @@ with gr.Blocks(css=assets.css) as demo:
|
|
77 |
gr.Markdown("## Output")
|
78 |
output = gr.Dataframe(headers=["Model", "Text", "Language", "Language Confidence","Time(s)"], label="Results", wrap=True)
|
79 |
|
80 |
-
submit.click(fn=sendToWhisper, inputs=[audio_record, audio_upload,
|
|
|
81 |
|
82 |
demo.launch()
|
|
|
11 |
|
12 |
import assets
|
13 |
|
14 |
+
def sendToWhisper(audio_record, audio_upload, without_timestamps):
|
15 |
results = []
|
16 |
|
17 |
audio = None
|
|
|
24 |
|
25 |
audio = whisper.load_audio(audio)
|
26 |
audio = whisper.pad_or_trim(audio)
|
27 |
+
|
28 |
+
start = datetime.now()
|
29 |
+
model = whisper.load_model(model_name)
|
30 |
+
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
31 |
+
# options = whisper.DecodingOptions(fp16 = False, without_timestamps=without_timestamps, task=task)
|
32 |
+
options = whisper.DecodingOptions()
|
33 |
+
output_text = whisper.decode(model, mel, options)
|
34 |
+
results.append([model_name, output_text.text, language, str(prob), str((datetime.now() - start).total_seconds())])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
return results
|
36 |
|
37 |
avail_models = whisper.available_models()
|
|
|
66 |
gr.Markdown("## Output")
|
67 |
output = gr.Dataframe(headers=["Model", "Text", "Language", "Language Confidence","Time(s)"], label="Results", wrap=True)
|
68 |
|
69 |
+
submit.click(fn=sendToWhisper, inputs=[audio_record, audio_upload, without_timestamps], outputs=output)
|
70 |
+
# [audio_record, audio_upload, task, models_selected, language_toggle, language_selected, without_timestamps], outputs=output)
|
71 |
|
72 |
demo.launch()
|