Skip to content

Commit e8d1287

Browse files
KarelVesely84danpovey
authored andcommitted
[src] Fix 'sausage-time' issue which occurs with disabled MBR decoding. (kaldi-asr#2996)
1 parent fd0aca9 commit e8d1287

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/lat/sausages.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ void MinimumBayesRisk::MbrDecode() {
5353
}
5454
// build the outputs (time, confidences),
5555
if (R_[q] != 0 || opts_.print_silence) {
56-
one_best_times_.push_back(times_[q][0]);
56+
// see which 'item' from the sausage-bin should we select,
57+
// (not necessarily the 1st one when MBR decoding disabled)
58+
int32 s = 0;
59+
for (int32 j=0; j<gamma_[q].size(); j++) {
60+
if (gamma_[q][j].first == R_[q]) {
61+
s = j;
62+
break;
63+
}
64+
}
65+
one_best_times_.push_back(times_[q][s]);
66+
// post-process the times,
5767
size_t i = one_best_times_.size();
5868
if (i > 1 && one_best_times_[i-2].second > one_best_times_[i-1].first) {
5969
// It's quite possible for this to happen, but it seems like it would
@@ -76,8 +86,12 @@ void MinimumBayesRisk::MbrDecode() {
7686
one_best_times_[i-1].second = right;
7787
}
7888
BaseFloat confidence = 0.0;
79-
for (int32 j = 0; j < gamma_[q].size(); j++)
80-
if (gamma_[q][j].first == R_[q]) confidence = gamma_[q][j].second;
89+
for (int32 j = 0; j < gamma_[q].size(); j++) {
90+
if (gamma_[q][j].first == R_[q]) {
91+
confidence = gamma_[q][j].second;
92+
break;
93+
}
94+
}
8195
one_best_confidences_.push_back(confidence);
8296
}
8397
}

0 commit comments

Comments
 (0)