Skip to content
10 changes: 7 additions & 3 deletions src/decoder/lattice-faster-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,11 @@ void LatticeFasterDecoder::ProcessNonemitting(BaseFloat cutoff) {
// problem did not improve overall speed.

KALDI_ASSERT(queue_.empty());
for (const Elem *e = toks_.GetList(); e != NULL; e = e->tail)
queue_.push_back(e->key);
for (const Elem *e = toks_.GetList(); e != NULL; e = e->tail) {
StateId state = e->key;
if (fst_.NumInputEpsilons(state) != 0)
queue_.push_back(state);
}
if (queue_.empty()) {
if (!warned_) {
KALDI_WARN << "Error, no surviving tokens: frame is " << frame;
Expand Down Expand Up @@ -850,7 +853,8 @@ void LatticeFasterDecoder::ProcessNonemitting(BaseFloat cutoff) {

// "changed" tells us whether the new token has a different
// cost from before, or is new [if so, add into queue].
if (changed) queue_.push_back(arc.nextstate);
if (changed && fst_.NumInputEpsilons(arc.nextstate) != 0)
queue_.push_back(arc.nextstate);
}
}
} // for all arcs
Expand Down
10 changes: 7 additions & 3 deletions src/decoder/lattice-faster-online-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,11 @@ void LatticeFasterOnlineDecoder::ProcessNonemitting(BaseFloat cutoff) {
// problem did not improve overall speed.

KALDI_ASSERT(queue_.empty());
for (const Elem *e = toks_.GetList(); e != NULL; e = e->tail)
queue_.push_back(e->key);
for (const Elem *e = toks_.GetList(); e != NULL; e = e->tail) {
StateId state = e->key;
if (fst_.NumInputEpsilons(state) != 0)
queue_.push_back(state);
}
if (queue_.empty()) {
if (!warned_) {
KALDI_WARN << "Error, no surviving tokens: frame is " << frame;
Expand Down Expand Up @@ -1030,7 +1033,8 @@ void LatticeFasterOnlineDecoder::ProcessNonemitting(BaseFloat cutoff) {

// "changed" tells us whether the new token has a different
// cost from before, or is new [if so, add into queue].
if (changed) queue_.push_back(arc.nextstate);
if (changed && fst_.NumInputEpsilons(arc.nextstate) != 0)
queue_.push_back(arc.nextstate);
}
}
} // for all arcs
Expand Down
6 changes: 4 additions & 2 deletions src/decoder/lattice-simple-decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ void LatticeSimpleDecoder::ProcessNonemitting() {
for (unordered_map<StateId, Token*>::iterator iter = cur_toks_.begin();
iter != cur_toks_.end();
++iter) {
queue.push_back(iter->first);
StateId state = iter->first;
if (fst_.NumInputEpsilons(state) != 0)
queue.push_back(state);
best_cost = std::min(best_cost, iter->second->tot_cost);
}
if (queue.empty()) {
Expand Down Expand Up @@ -604,7 +606,7 @@ void LatticeSimpleDecoder::ProcessNonemitting() {

// "changed" tells us whether the new token has a different
// cost from before, or is new [if so, add into queue].
if (changed)
if (changed && fst_.NumInputEpsilons(arc.nextstate) != 0)
queue.push_back(arc.nextstate);
}
}
Expand Down