Skip to content

Commit

Permalink
Fix 'sausage-time' issue which occurs with disabled MBR decoding.
Browse files Browse the repository at this point in the history
- the issue was introduced in kaldi-asr#2972 and was addressed in kaldi-asr#2993
  • Loading branch information
KarelVesely84 committed Jan 17, 2019
1 parent fd0aca9 commit ed8d45d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/lat/sausages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ void MinimumBayesRisk::MbrDecode() {
}
// build the outputs (time, confidences),
if (R_[q] != 0 || opts_.print_silence) {
one_best_times_.push_back(times_[q][0]);
// see which 'item' from the sausage-bin should we select,
// (not necessarily the 1st one when MBR decoding disabled)
int32 s = 0;
for (int32 j=0; j<gamma_[q].size(); j++) {
if (gamma_[q][j].first == R_[q]) {
s = j;
break;
}
}
one_best_times_.push_back(times_[q][s]);
// post-process the times,
size_t i = one_best_times_.size();
if (i > 1 && one_best_times_[i-2].second > one_best_times_[i-1].first) {
// It's quite possible for this to happen, but it seems like it would
Expand All @@ -76,8 +86,12 @@ void MinimumBayesRisk::MbrDecode() {
one_best_times_[i-1].second = right;
}
BaseFloat confidence = 0.0;
for (int32 j = 0; j < gamma_[q].size(); j++)
if (gamma_[q][j].first == R_[q]) confidence = gamma_[q][j].second;
for (int32 j = 0; j < gamma_[q].size(); j++) {
if (gamma_[q][j].first == R_[q]) {
confidence = gamma_[q][j].second;
break;
}
}
one_best_confidences_.push_back(confidence);
}
}
Expand Down

0 comments on commit ed8d45d

Please sign in to comment.