File size: 647 Bytes
61ba593
 
752ce9b
61ba593
752ce9b
61ba593
 
 
 
 
 
 
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
25
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