File size: 605 Bytes
752ce9b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from huggingface_hub import login
import json
import evaluate
import os
def hf_login():
hf_token = os.getenv("HF_TOKEN")
# if hf_token is None:
# with open("credentials.json", "r") as f:
# hf_token = json.load(f)["token"]
login(token=hf_token)
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
|