from local

This commit is contained in:
dohe0342 2023-02-02 19:18:48 +09:00
parent 73a1d39c86
commit b70122039d
2 changed files with 18 additions and 3 deletions

View File

@ -453,6 +453,12 @@ def decode_dataset(
num_batches = "?" num_batches = "?"
results = defaultdict(list) results = defaultdict(list)
subs_all = 0
dels_all = 0
ins_all = 0
char_num = 0
for batch_idx, batch in enumerate(dl): for batch_idx, batch in enumerate(dl):
#logging.info(f"decoding {batch_idx} th batch") #logging.info(f"decoding {batch_idx} th batch")
texts = batch["supervisions"]["text"] texts = batch["supervisions"]["text"]
@ -483,9 +489,18 @@ def decode_dataset(
) )
for i, hyp in enumerate(hyps): for i, hyp in enumerate(hyps):
print('hyp = ', hyp) #print('hyp = ', hyp)
print('ref = ', texts[i].replace(' ', '')) #print('ref = ', texts[i].replace(' ', ''))
print('') #print('')
ref = texts[i].replace(' ', '')
[cer, subs, dels, ins] = metrics.get_cer(hyp, ref)
subs_all += subs
dels_all += dels
ins_all += ins
char_num == len(ref)
cer = (subs_all+dels_all+ins_all) / char_num
print(cer * 100)
''' '''
for lm_scale, hyps in hyps_dict.items(): for lm_scale, hyps in hyps_dict.items():