|
import gradio as gr |
|
from dataset import Dataset |
|
from model import Model |
|
from utils import compute_wer |
|
|
|
|
|
|
|
|
|
from huggingface_hub import login |
|
import os |
|
|
|
hf_token = os.getenv("HF_Token") |
|
login(hf_token) |
|
|
|
|
|
dataset = Dataset() |
|
models = Model() |
|
|
|
|
|
def run_tests (dataset_choice:str, model:str): |
|
|
|
MoDeL = Model() |
|
MoDeL.select(model) |
|
MoDeL.load() |
|
DaTaSeT = Dataset(100) |
|
DaTaSeT.load(dataset_choice) |
|
references, predictions = MoDeL.process(DaTaSeT) |
|
wer = compute_wer(references=references, predictions=predictions) |
|
return wer |
|
|
|
|
|
def eval(data_subset:str, model_1:str, model_2:str)->str: |
|
|
|
wer_result_1 = run_tests(data_subset, model_1) |
|
wer_result_2 = run_tests(data_subset, model_2) |
|
|
|
return f"WER Score: {wer_result_1}", f"WER Score: {wer_result_2}" |
|
|
|
def get_card(selected_model:str)->str: |
|
|
|
with open("cards.txt", "r") as f: |
|
cards = f.read() |
|
|
|
cards = cards.split("@@") |
|
for card in cards: |
|
if "ID: "+selected_model in card: |
|
return card |
|
|
|
return "Unknown Model" |
|
|
|
def is_own(data_subset:str): |
|
if data_subset == "own": |
|
own_audio = gr.Audio(sources=['microphone'],streaming=False) |
|
own_transcription = gr.TextArea(lines=2) |
|
return own_audio, own_transcription |
|
own_audio = None |
|
own_transcription = None |
|
return own_audio, own_transcription |
|
|
|
with gr.Blocks() as demo: |
|
|
|
|
|
gr.Markdown('# <p style="text-align: center;">VocalVenturer 💬</p>') |
|
gr.Markdown("-------") |
|
gr.Markdown("""#### Hello there, this is the VocalVenturer, this app is aimed at helping you making more informed model choices for ASR. Please choose a Data Subset to evalutate the Models on. You also have the opportunity to record and transcibe an own sample. The Models will be evaluated using the *WER* metric -> here is an amazing Leaderboard for it LINK""") |
|
|
|
with gr.Row(): |
|
with gr.Column(scale=1): |
|
pass |
|
with gr.Column(scale=5): |
|
data_subset = gr.Radio( |
|
value="LibriSpeech Clean", |
|
choices=dataset.get_options(), |
|
label="Data subset / Own Sample", |
|
) |
|
with gr.Column(scale=1): |
|
pass |
|
|
|
with gr.Row(): |
|
own_audio = gr.Audio(sources=['microphone'],streaming=False,visible=False) |
|
own_transcription = gr.TextArea(lines=2, visible=False) |
|
|
|
data_subset.change(is_own, inputs=[data_subset], outputs=[own_audio, own_transcription]) |
|
|
|
|
|
with gr.Row(): |
|
|
|
with gr.Column(scale=1): |
|
model_1 = gr.Dropdown( |
|
choices=models.get_options(), |
|
label="Select Model" |
|
) |
|
model_1_card = gr.Markdown("") |
|
|
|
with gr.Column(scale=1): |
|
model_2 = gr.Dropdown( |
|
choices=models.get_options(), |
|
label="Select Model" |
|
) |
|
model_2_card = gr.Markdown("") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model_1.change(get_card, inputs=model_1, outputs=model_1_card) |
|
model_2.change(get_card, inputs=model_2, outputs=model_2_card) |
|
|
|
|
|
eval_btn = gr.Button( |
|
value="Evaluate", |
|
variant="primary", |
|
size="sm" |
|
) |
|
|
|
|
|
|
|
gr.Markdown('## <p style="text-align: center;">Results</p>') |
|
gr.Markdown("-------") |
|
|
|
|
|
with gr.Row(): |
|
|
|
with gr.Column(scale=1): |
|
results_model_1 = gr.Markdown("") |
|
|
|
with gr.Column(scale=1): |
|
results_model_2 = gr.Markdown("") |
|
|
|
eval_btn.click(eval, [data_subset, model_1, model_2], [results_model_1, results_model_2]) |
|
|
|
|
|
|
|
demo.launch(debug=True) |