Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ def update_passage(passage_name):
|
|
24 |
|
25 |
return sum, "", gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
26 |
|
27 |
-
def inference(audio):
|
28 |
audio = whisper.load_audio(audio)
|
29 |
audio_length = audio.shape[-1]/16000
|
30 |
audio = whisper.pad_or_trim(audio)
|
@@ -45,16 +45,16 @@ def inference(audio):
|
|
45 |
])
|
46 |
|
47 |
error = jiwer.wer(
|
48 |
-
|
49 |
result.text,
|
50 |
truth_transform=transformation,
|
51 |
hypothesis_transform=transformation
|
52 |
)
|
53 |
# error = jiwer.wer(passage, result.text)
|
54 |
-
we_num = error * len(
|
55 |
# print(f"WER is {we_num}")
|
56 |
print(result.text)
|
57 |
-
print(
|
58 |
|
59 |
return f"For a {audio_length} second audio, {we_num} errors were made, resulting in a final time of {audio_length + we_num}.\n\n{result.text}", gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
60 |
|
@@ -229,7 +229,7 @@ with block:
|
|
229 |
|
230 |
|
231 |
|
232 |
-
btn.click(inference, inputs=[audio], outputs=[text, community_icon, loading_icon, share_button])
|
233 |
btn2.click(update_passage, inputs=[passage_name], outputs=[passage, text, community_icon, loading_icon, share_button])
|
234 |
share_button.click(None, [], [], _js=share_js)
|
235 |
|
|
|
24 |
|
25 |
return sum, "", gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
26 |
|
27 |
+
def inference(audio, gt: str):
|
28 |
audio = whisper.load_audio(audio)
|
29 |
audio_length = audio.shape[-1]/16000
|
30 |
audio = whisper.pad_or_trim(audio)
|
|
|
45 |
])
|
46 |
|
47 |
error = jiwer.wer(
|
48 |
+
gt,
|
49 |
result.text,
|
50 |
truth_transform=transformation,
|
51 |
hypothesis_transform=transformation
|
52 |
)
|
53 |
# error = jiwer.wer(passage, result.text)
|
54 |
+
we_num = error * len(gt.split())
|
55 |
# print(f"WER is {we_num}")
|
56 |
print(result.text)
|
57 |
+
print(gt)
|
58 |
|
59 |
return f"For a {audio_length} second audio, {we_num} errors were made, resulting in a final time of {audio_length + we_num}.\n\n{result.text}", gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
60 |
|
|
|
229 |
|
230 |
|
231 |
|
232 |
+
btn.click(inference, inputs=[audio, passage.value], outputs=[text, community_icon, loading_icon, share_button])
|
233 |
btn2.click(update_passage, inputs=[passage_name], outputs=[passage, text, community_icon, loading_icon, share_button])
|
234 |
share_button.click(None, [], [], _js=share_js)
|
235 |
|