File size: 330 Bytes
0b32ad6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from s3prl.metric import cer, per, wer


def isclose(x: float, y: float) -> float:
    return abs(x - y) < 1e-9


def test_metric():
    # test wer & cer
    hyps = ["a ac abb d"]
    refs = ["a ab abc d"]

    assert isclose(cer(hyps, refs), 0.2)
    assert isclose(wer(hyps, refs), 0.5)
    assert isclose(per(hyps, refs), 0.5)