Skip to content

Commit 0627644

Browse files
authored
[src] Fix for how lattice-incremental-decoder deals with failure (#3855)
1 parent 4bbacd0 commit 0627644

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/decoder/lattice-incremental-decoder.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,16 @@ const CompactLattice& LatticeIncrementalDecoderTpl<FST, Token>::GetLattice(
873873
KALDI_ASSERT(num_frames_to_include >= num_frames_in_lattice_ &&
874874
num_frames_to_include <= NumFramesDecoded());
875875

876+
877+
if (num_frames_in_lattice_ > 0 &&
878+
determinizer_.GetLattice().NumStates() == 0) {
879+
/* Something went wrong, lattice is empty and will continue to be empty.
880+
User-level code should detect and deal with this.
881+
*/
882+
num_frames_in_lattice_ = num_frames_to_include;
883+
return determinizer_.GetLattice();
884+
}
885+
876886
if (decoding_finalized_ && !use_final_probs) {
877887
// This is not supported
878888
KALDI_ERR << "You cannot get the lattice without final-probs after "
@@ -1044,6 +1054,9 @@ const CompactLattice& LatticeIncrementalDecoderTpl<FST, Token>::GetLattice(
10441054
// We are ignoring the return status, which say whether it finished before the beam.
10451055

10461056
num_frames_in_lattice_ = num_frames_to_include;
1057+
1058+
if (determinizer_.GetLattice().NumStates() == 0)
1059+
return determinizer_.GetLattice(); // Something went wrong, lattice is empty.
10471060
}
10481061

10491062
unordered_map<Token*, BaseFloat> token2final_cost;

0 commit comments

Comments
 (0)