from huggingface_hub import login import json import evaluate import os def hf_login(): hf_token = os.getenv("HF_Token") print(hf_token) if hf_token is None: with open("credentials.json", "r") as f: hf_token = json.load(f)["token"] login(token=hf_token, add_to_git_credential=True) def data(dataset): for i, item in enumerate(dataset): yield {**item["audio"], "reference": item["norm_text"]} def compute_wer(references, predictions): wer_metric = evaluate.load("wer") wer = wer_metric.compute(references=references, predictions=predictions) wer = round(100 * wer, 2) return wer