File size: 1,261 Bytes
4c8c593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
import json

# 你的输入文件路径
jsonl_path = "/data2/t-yihanwu/projects/Versa/versa/clean_TTS_wer"
# "results/VCTK_Demand_miipher-joint-GANloss-noisyspk-90ksteps_wer"
# "results/podcast_humanLabeled_enUS_segments_wav_miipher-joint-GANloss-noisyspk-miipher-frozen-800ksteps_wer"


total_insert = 0
total_delete = 0
total_replace = 0
total_ref_words = 0

with open(jsonl_path, "r", encoding="utf-8") as f:
    for line in f:
        entry = json.loads(line)
        ins = entry["whisper_wer_insert"]
        dele = entry["whisper_wer_delete"]
        repl = entry["whisper_wer_replace"]
        equal = entry["whisper_wer_equal"]

        total_insert += ins
        total_delete += dele
        total_replace += repl
        total_ref_words += (ins + dele + repl + equal)

# 避免除以零
if total_ref_words == 0:
    print("No words in reference. Cannot compute WER.")
else:
    wer = (total_insert + total_delete + total_replace) / total_ref_words
    print(f"Total Insertions: {total_insert / total_ref_words}")
    print(f"Total Deletions: {total_delete/ total_ref_words}")
    print(f"Total Replacements: {total_replace/ total_ref_words}")
    print(f"Total Reference Words: {total_ref_words/ total_ref_words}")
    print(f"Total WER: {wer:.4f}")