large_v2_nan_tw_so_short_30s / ji_remove_repeat.py
thomas0104's picture
Upload 26 files
aee2b04
raw
history blame
772 Bytes
import jiwer
import ast
p = open('pred.txt','r',encoding="utf-8")
l = open('label.txt','r',encoding="utf-8")
pred = p.readline().split('=')[1]
label = l.readline().split('=')[1]
pred = ast.literal_eval(pred) # list like str to list
label = ast.literal_eval(label)
for i in range(len(pred)):
pred[i] = "".join(dict.fromkeys(pred[i])).replace(' ','')
for i in range(len(label)):
label[i] = "".join(dict.fromkeys(label[i])).replace(' ','')
print(pred[0])
print(label[0])
wer = jiwer.wer(label, pred)
print(f'{wer=}')
'''
pred = pred.replace(' ', '')
label = label.replace(' ', '')
'''
cer = jiwer.cer(label, pred)
print(f'{cer=}')
q = open('modify_pred.txt','w',encoding="utf-8")
q.write(f'{pred=}')
a = open('modify_label.txt','w',encoding="utf-8")
a.write(f'{label=}')