Ejemplo n.º 1
0
def run(args):
    hyp_reader = TransReader(args.hyp)
    ref_reader = TransReader(args.ref)
    if len(hyp_reader) != len(ref_reader):
        raise RuntimeError(
            "Looks number of speakers do not match in hyp & ref")
    each_utt = open(args.per_utt, "w") if args.per_utt else None

    reporter = Report(args.utt2class)
    for key, hyp in hyp_reader:
        ref = ref_reader[key]
        err = permute_ed(hyp, ref)
        ref_len = sum([len(r) for r in ref])
        if each_utt:
            if ref_len != 0:
                each_utt.write("{}\t{:.3f}\n".format(key, err / ref_len))
            else:
                each_utt.write("{}\tINF\n".format(key))
        reporter.add(key, err, ref_len)
    reporter.report()
Ejemplo n.º 2
0
def run(args):
    hyp_reader = TransReader(args.hyp)
    ref_reader = TransReader(args.ref)
    if len(hyp_reader) != len(ref_reader):
        raise RuntimeError(
            "Looks number of speakers do not match in hyp & ref")
    each_utt = open(args.per_utt, "w") if args.per_utt else None

    err = 0
    tot = 0
    for key, hyp in hyp_reader:
        ref = ref_reader[key]
        dst = permute_ed(hyp, ref)
        ref_len = sum([len(r) for r in ref])
        if each_utt:
            if ref_len != 0:
                each_utt.write("{}\t{:.3f}\n".format(key, dst / ref_len))
            else:
                each_utt.write("{}\tINF\n".format(key))
        err += dst
        tot += ref_len
    print("WER: {:.2f}%".format(err * 100 / tot))