LatticeIncrementalOnlineDecoderTpl is as LatticeIncrementalDecoderTpl but also supports an efficient way to get the best path (see the function BestPathEnd()), which is useful in endpointing and in situations where you might want to frequently access the best path. More...
#include <lattice-incremental-online-decoder.h>
Classes | |
struct | BestPathIterator |
Public Types | |
using | Arc = typename FST::Arc |
using | Label = typename Arc::Label |
using | StateId = typename Arc::StateId |
using | Weight = typename Arc::Weight |
using | Token = decoder::BackpointerToken |
using | ForwardLinkT = decoder::ForwardLink< Token > |
Public Types inherited from LatticeIncrementalDecoderTpl< FST, decoder::BackpointerToken > | |
using | Arc = typename FST::Arc |
using | Label = typename Arc::Label |
using | StateId = typename Arc::StateId |
using | Weight = typename Arc::Weight |
using | ForwardLinkT = decoder::ForwardLink< decoder::BackpointerToken > |
Public Member Functions | |
LatticeIncrementalOnlineDecoderTpl (const FST &fst, const TransitionModel &trans_model, const LatticeIncrementalDecoderConfig &config) | |
LatticeIncrementalOnlineDecoderTpl (const LatticeIncrementalDecoderConfig &config, FST *fst, const TransitionModel &trans_model) | |
bool | GetBestPath (Lattice *ofst, bool use_final_probs=true) const |
Outputs an FST corresponding to the single best path through the lattice. More... | |
BestPathIterator | BestPathEnd (bool use_final_probs, BaseFloat *final_cost=NULL) const |
This function returns an iterator that can be used to trace back the best path. More... | |
BestPathIterator | TraceBackBestPath (BestPathIterator iter, LatticeArc *arc) const |
This function can be used in conjunction with BestPathEnd() to trace back the best path one link at a time (e.g. More... | |
KALDI_DISALLOW_COPY_AND_ASSIGN (LatticeIncrementalOnlineDecoderTpl) | |
Public Member Functions inherited from LatticeIncrementalDecoderTpl< FST, decoder::BackpointerToken > | |
LatticeIncrementalDecoderTpl (const FST &fst, const TransitionModel &trans_model, const LatticeIncrementalDecoderConfig &config) | |
LatticeIncrementalDecoderTpl (const LatticeIncrementalDecoderConfig &config, FST *fst, const TransitionModel &trans_model) | |
void | SetOptions (const LatticeIncrementalDecoderConfig &config) |
const LatticeIncrementalDecoderConfig & | GetOptions () const |
~LatticeIncrementalDecoderTpl () | |
bool | Decode (DecodableInterface *decodable) |
CAUTION: it's unlikely that you will ever want to call this function. More... | |
bool | ReachedFinal () const |
says whether a final-state was active on the last frame. More... | |
const CompactLattice & | GetLattice (int32 num_frames_to_include, bool use_final_probs=false) |
This decoder has no GetBestPath() function. More... | |
int | NumFramesInLattice () const |
void | InitDecoding () |
InitDecoding initializes the decoding, and should only be used if you intend to call AdvanceDecoding(). More... | |
void | AdvanceDecoding (DecodableInterface *decodable, int32 max_num_frames=-1) |
This will decode until there are no more frames ready in the decodable object. More... | |
BaseFloat | FinalRelativeCost () const |
FinalRelativeCost() serves the same purpose as ReachedFinal(), but gives more information. More... | |
int32 | NumFramesDecoded () const |
Returns the number of frames decoded so far. More... | |
void | FinalizeDecoding () |
Finalizes the decoding, doing an extra pruning step on the last frame that uses the final-probs. More... | |
LatticeIncrementalOnlineDecoderTpl is as LatticeIncrementalDecoderTpl but also supports an efficient way to get the best path (see the function BestPathEnd()), which is useful in endpointing and in situations where you might want to frequently access the best path.
This is only templated on the FST type, since the Token type is required to be BackpointerToken. Actually it only makes sense to instantiate LatticeIncrementalDecoderTpl with Token == BackpointerToken if you do so indirectly via this child class.
Definition at line 51 of file lattice-incremental-online-decoder.h.
using Arc = typename FST::Arc |
Definition at line 54 of file lattice-incremental-online-decoder.h.
using ForwardLinkT = decoder::ForwardLink<Token> |
Definition at line 59 of file lattice-incremental-online-decoder.h.
using Label = typename Arc::Label |
Definition at line 55 of file lattice-incremental-online-decoder.h.
using StateId = typename Arc::StateId |
Definition at line 56 of file lattice-incremental-online-decoder.h.
using Token = decoder::BackpointerToken |
Definition at line 58 of file lattice-incremental-online-decoder.h.
using Weight = typename Arc::Weight |
Definition at line 57 of file lattice-incremental-online-decoder.h.
|
inline |
Definition at line 64 of file lattice-incremental-online-decoder.h.
|
inline |
Definition at line 71 of file lattice-incremental-online-decoder.h.
LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator BestPathEnd | ( | bool | use_final_probs, |
BaseFloat * | final_cost = NULL |
||
) | const |
This function returns an iterator that can be used to trace back the best path.
If use_final_probs == true and at least one final state survived till the end, it will use the final-probs in working out the best final Token, and will output the final cost to *final_cost (if non-NULL), else it will use only the forward likelihood, and will put zero in *final_cost (if non-NULL). Requires that NumFramesDecoded() > 0.
Definition at line 54 of file lattice-incremental-online-decoder.cc.
References KALDI_ASSERT, KALDI_ERR, KALDI_WARN, and BackpointerToken::next.
Referenced by OnlineSilenceWeighting::ComputeCurrentTraceback(), and LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::Done().
Outputs an FST corresponding to the single best path through the lattice.
This is quite efficient because it doesn't get the entire raw lattice and find the best path through it; instead, it uses the BestPathEnd and BestPathIterator so it basically traces it back through the lattice. Returns true if result is nonempty (using the return status is deprecated, it will become void). If "use_final_probs" is true AND we reached the final-state of the graph then it will include those as final-probs, else it will treat all final-probs as one.
Definition at line 32 of file lattice-incremental-online-decoder.cc.
References LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::Done().
Referenced by LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::Done().
KALDI_DISALLOW_COPY_AND_ASSIGN | ( | LatticeIncrementalOnlineDecoderTpl< FST > | ) |
LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator TraceBackBestPath | ( | BestPathIterator | iter, |
LatticeArc * | arc | ||
) | const |
This function can be used in conjunction with BestPathEnd() to trace back the best path one link at a time (e.g.
this can be useful in endpoint detection). By "link" we mean a link in the graph; not all links cross frame boundaries, but each time you see a nonzero ilabel you can interpret that as a frame. The return value is the updated iterator. It outputs the ilabel and olabel, and the (graph and acoustic) weight to the "arc" pointer, while leaving its "nextstate" variable unchanged.
Definition at line 108 of file lattice-incremental-online-decoder.cc.
References ForwardLink< Token >::acoustic_cost, LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::Done(), LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::frame, ForwardLink< Token >::graph_cost, ForwardLink< Token >::ilabel, KALDI_ASSERT, KALDI_ERR, ForwardLink< Token >::next, ForwardLink< Token >::next_tok, ForwardLink< Token >::olabel, LatticeWeightTpl< BaseFloat >::One(), and LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::tok.
Referenced by OnlineSilenceWeighting::ComputeCurrentTraceback(), and LatticeIncrementalOnlineDecoderTpl< FST >::BestPathIterator::Done().