File size: 1,147 Bytes
31eaa34 0552670 a505be2 31eaa34 5c80035 0552670 31eaa34 0552670 31eaa34 0552670 31eaa34 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import gradio as gr
import pandas as pd
from jiwer import wer
import re
import os
REGEX_YAML_BLOCK = re.compile(r"---[\n\r]+([\S\s]*?)[\n\r]+---[\n\r]")
def parse_readme(filepath):
"""Parses a repositories README and removes"""
if not os.path.exists(filepath):
return "No README.md found."
with open(filepath, "r") as f:
text = f.read()
match = REGEX_YAML_BLOCK.search(text)
if match:
text = text[match.end() :]
return text
def compute(input):
preds = input['prediction'].tolist()
truths = input['truth'].tolist()
print(truths, preds, type(truths))
err = wer(truths, preds)
print(err)
return err
description = "This is a calculator that you can use to find WER"
demo = gr.Interface(
fn=compute,
inputs=gr.components.Dataframe(
headers=["truth", "prediction"],
col_count=2,
row_count=1,
label="Input"
),
outputs=gr.components.Textbox(label="WER"),
description=description,
title="WER Calculator",
article=parse_readme("README.md")
)
demo.launch()
|