CoolFace
Apppublic

themechanism/script_fidelity_rate

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes
app.py58 linesDownload Raw Back to root
1import gradio as gr2 3from script_fidelity import compute_corpus_sfr, list_languages4 5 6EXAMPLE_TEXT = "کابل کې ښه هوا ده\nromanized output"7 8 9def _score(predictions_text: str, language: str, digit_policy: str) -> dict:10    predictions = [11        line.strip()12        for line in (predictions_text or "").splitlines()13        if line.strip()14    ]15    if not predictions:16        return {"error": "Enter at least one prediction."}17 18    return compute_corpus_sfr(19        predictions,20        language=language,21        digit_policy=digit_policy,22        return_details=True,23    )24 25 26with gr.Blocks(title="Script Fidelity Rate") as demo:27    gr.Markdown(28        "# Script Fidelity Rate\n"29        "Reference-free script check for multilingual ASR. "30        "Enter one prediction per line."31    )32    with gr.Row():33        language = gr.Dropdown(34            choices=list_languages(),35            value="ps_af",36            label="FLEURS language",37        )38        digit_policy = gr.Radio(39            choices=["count", "ignore"],40            value="count",41            label="Digit policy",42        )43 44    predictions = gr.Textbox(45        value=EXAMPLE_TEXT,46        lines=6,47        label="Predictions",48    )49    button = gr.Button("Compute SFR")50    output = gr.JSON(label="Result")51 52    button.click(_score, [predictions, language, digit_policy], output)53    predictions.submit(_score, [predictions, language, digit_policy], output)54 55 56if __name__ == "__main__":57    demo.launch()58