import sys if __name__ == '__main__': word_error_rate = 0 number_of_sentence = 0 correct_sentences = 0 with open(sys.argv[1], 'r') as sclite_result, \ open('new_wer.txt', 'w') as wer, \ open('srr.txt', 'a+') as srr: for line in sclite_result: complited = False if line[:7] == 'Scores:': number_of_sentence += 1 c, s, d, i = line.strip().split()[-4:] word_error_rate = sum(map(int, [s, d, i])) / sum(map(int, [s, d, c])) complited = True if complited: wer.write(f'{word_error_rate:.6f}\n') if word_error_rate == 0: correct_sentences += 1 sentence_recognition_rate = correct_sentences / number_of_sentence srr.write(f'{sentence_recognition_rate:.6f}\n')