Blame view

egs/fisher_callhome_spanish/s5/local/decode_report.py 4.83 KB
8dcb6dfcb   Yannick Estève   first commit
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
  #!/usr/bin/env python
  
  # Author : Gaurav Kumar (Johns Hopkins University)
  # Gets a report on what the best word error rate was and which iteration
  # led to it. This is needed both for reporting purposes and for setting
  # the acoustic scale weight which extracting lattices.
  # This script is specific to my partitions and needs to be made more general
  # or modified
  
  from __future__ import print_function
  import subprocess
  import os
  
  decode_directories = ['exp/tri5a/decode_dev',
                          'exp/tri5a/decode_test',
                          'exp/tri5a/decode_dev2',
                          'exp/sgmm2x_6a/decode_dev_fmllr',
                          'exp/sgmm2x_6a/decode_test_fmllr',
                          'exp/sgmm2x_6a/decode_dev2_fmllr',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_it1',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_it2',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_it3',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_it4',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_it1',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_it2',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_it3',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_it4',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_it1',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_it2',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_it3',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_it4',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_fmllr_it1',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_fmllr_it2',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_fmllr_it3',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev_fmllr_it4',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_fmllr_it1',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_fmllr_it2',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_fmllr_it3',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_dev2_fmllr_it4',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_fmllr_it1',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_fmllr_it2',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_fmllr_it3',
                          'exp/sgmm2x_6a_mmi_b0.2/decode_test_fmllr_it4'
                          ]
  
  def get_best_wer(decode_dir):
      best_iteration = 0
      best_wer = 100.0
      for i in range(16):
          if os.path.isfile("{}/wer_{}".format(decode_dir, i)):
              result = subprocess.check_output("tail -n 3 {}/wer_{}".format(decode_dir, i), shell=True)
              wer_string = result.split("
  ")[0]
              wer_details = wer_string.split(' ')
              # Get max WER
              wer = float(wer_details[1])
              if wer < best_wer:
                  best_wer = wer
                  best_iteration = i
      return best_iteration, best_wer
  
  for decode_dir in decode_directories[:6]:
      print(decode_dir)
      print(get_best_wer(decode_dir))
  
  # Separate processing for bMMI stuff
  best_wer = 100.0
  best_dir = ""
  best_iteration = 0
  
  for decode_dir in decode_directories[6:10]:
      iteration, wer = get_best_wer(decode_dir)
      if wer < best_wer:
          best_wer = wer
          best_dir = decode_dir
          best_iteration = iteration
  
  print(best_dir)
  print((best_iteration, best_wer))
  
  best_wer = 100.0
  best_dir = ""
  best_iteration = 0
  
  for decode_dir in decode_directories[10:14]:
      iteration, wer = get_best_wer(decode_dir)
      if wer < best_wer:
          best_wer = wer
          best_dir = decode_dir
          best_iteration = iteration
  
  print(best_dir)
  print((best_iteration, best_wer))
  
  best_wer = 100.0
  best_dir = ""
  best_iteration = 0
  
  for decode_dir in decode_directories[14:18]:
      iteration, wer = get_best_wer(decode_dir)
      if wer < best_wer:
          best_wer = wer
          best_dir = decode_dir
          best_iteration = iteration
  
  print(best_dir)
  print((best_iteration, best_wer))
  
  best_wer = 100.0
  best_dir = ""
  best_iteration = 0
  
  for decode_dir in decode_directories[18:22]:
      iteration, wer = get_best_wer(decode_dir)
      if wer <= best_wer:
          best_wer = wer
          best_dir = decode_dir
          best_iteration = iteration
  
  print(best_dir)
  print((best_iteration, best_wer))
  
  best_wer = 100.0
  best_dir = ""
  best_iteration = 0
  
  for decode_dir in decode_directories[22:26]:
      iteration, wer = get_best_wer(decode_dir)
      if wer <= best_wer:
          best_wer = wer
          best_dir = decode_dir
          best_iteration = iteration
  
  print(best_dir)
  print((best_iteration, best_wer))
  
  best_wer = 100.0
  best_dir = ""
  best_iteration = 0
  
  for decode_dir in decode_directories[26:]:
      iteration, wer = get_best_wer(decode_dir)
      if wer <= best_wer:
          best_wer = wer
          best_dir = decode_dir
          best_iteration = iteration
  
  print(best_dir)
  print((best_iteration, best_wer))