-
Notifications
You must be signed in to change notification settings - Fork 64
/
benchmark.py
32 lines (22 loc) · 962 Bytes
/
benchmark.py
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
26
27
28
29
30
31
32
import argparse
import editdistance
from dataset import *
from engine import *
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--engine_type', type=str, required=True)
args = parser.parse_args()
dataset = Dataset.create('librispeech')
print('loaded %s with %.2f hours of data' % (str(dataset), dataset.size_hours()))
engine = ASREngine.create(ASREngines[args.engine_type])
print('created %s engine' % str(engine))
word_error_count = 0
word_count = 0
for i in range(dataset.size()):
path, ref_transcript = dataset.get(i)
transcript = engine.transcribe(path)
ref_words = ref_transcript.strip('\n ').lower().split()
words = transcript.strip('\n ').lower().split()
word_error_count += editdistance.eval(ref_words, words)
word_count += len(ref_words)
print('word error rate : %.2f' % (100 * float(word_error_count) / word_count))