Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,7 @@ import wikipedia
|
|
| 3 |
os.system("pip install git+https://github.com/openai/whisper.git")
|
| 4 |
import gradio as gr
|
| 5 |
import whisper
|
| 6 |
-
|
| 7 |
-
|
| 8 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 9 |
|
| 10 |
model = whisper.load_model("small")
|
|
@@ -24,12 +23,25 @@ def inference(audio):
|
|
| 24 |
options = whisper.DecodingOptions(fp16 = False)
|
| 25 |
result = whisper.decode(model, mel, options)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
print(result.text)
|
| 31 |
print(passage)
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
|
|
|
|
| 3 |
os.system("pip install git+https://github.com/openai/whisper.git")
|
| 4 |
import gradio as gr
|
| 5 |
import whisper
|
| 6 |
+
import jiwer
|
|
|
|
| 7 |
from share_btn import community_icon_html, loading_icon_html, share_js
|
| 8 |
|
| 9 |
model = whisper.load_model("small")
|
|
|
|
| 23 |
options = whisper.DecodingOptions(fp16 = False)
|
| 24 |
result = whisper.decode(model, mel, options)
|
| 25 |
|
| 26 |
+
transformation = jiwer.Compose([
|
| 27 |
+
jiwer.ToLowerCase(),
|
| 28 |
+
jiwer.RemoveWhiteSpace(replace_by_space=True),
|
| 29 |
+
jiwer.RemoveMultipleSpaces(),
|
| 30 |
+
jiwer.ReduceToListOfListOfWords(word_delimiter=" ")
|
| 31 |
+
])
|
| 32 |
|
| 33 |
+
error = jiwer.wer(
|
| 34 |
+
passage,
|
| 35 |
+
result.text,
|
| 36 |
+
truth_transform=transformation,
|
| 37 |
+
hypothesis_transform=transformation
|
| 38 |
+
)
|
| 39 |
+
# error = jiwer.wer(passage, result.text)
|
| 40 |
+
print(f"WER is {error * len(result.text.split())}")
|
| 41 |
print(result.text)
|
| 42 |
print(passage)
|
| 43 |
+
|
| 44 |
+
return f"WER is {error * len(result.text.split())} \n\n{result.text}", gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
| 45 |
|
| 46 |
|
| 47 |
|