LatticeFasterOnlineDecoderTpl is as LatticeFasterDecoderTpl 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-faster-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 LatticeFasterDecoderTpl< 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 | |
LatticeFasterOnlineDecoderTpl (const FST &fst, const LatticeFasterDecoderConfig &config) | |
LatticeFasterOnlineDecoderTpl (const LatticeFasterDecoderConfig &config, FST *fst) | |
bool | GetBestPath (Lattice *ofst, bool use_final_probs=true) const |
Outputs an FST corresponding to the single best path through the lattice. More... | |
bool | TestGetBestPath (bool use_final_probs=true) const |
This function does a self-test of GetBestPath(). 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... | |
bool | GetRawLatticePruned (Lattice *ofst, bool use_final_probs, BaseFloat beam) const |
Behaves the same as GetRawLattice but only processes tokens whose extra_cost is smaller than the best-cost plus the specified beam. More... | |
KALDI_DISALLOW_COPY_AND_ASSIGN (LatticeFasterOnlineDecoderTpl) | |
Public Member Functions inherited from LatticeFasterDecoderTpl< FST, decoder::BackpointerToken > | |
LatticeFasterDecoderTpl (const FST &fst, const LatticeFasterDecoderConfig &config) | |
LatticeFasterDecoderTpl (const LatticeFasterDecoderConfig &config, FST *fst) | |
void | SetOptions (const LatticeFasterDecoderConfig &config) |
const LatticeFasterDecoderConfig & | GetOptions () const |
~LatticeFasterDecoderTpl () | |
bool | Decode (DecodableInterface *decodable) |
Decodes until there are no more frames left in the "decodable" object. More... | |
bool | ReachedFinal () const |
says whether a final-state was active on the last frame. More... | |
bool | GetBestPath (Lattice *ofst, bool use_final_probs=true) const |
Outputs an FST corresponding to the single best path through the lattice. More... | |
bool | GetRawLattice (Lattice *ofst, bool use_final_probs=true) const |
Outputs an FST corresponding to the raw, state-level tracebacks. More... | |
bool | GetLattice (CompactLattice *ofst, bool use_final_probs=true) const |
[Deprecated, users should now use GetRawLattice and determinize it themselves, e.g. More... | |
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... | |
void | FinalizeDecoding () |
This function may be optionally called after AdvanceDecoding(), when you do not plan to decode any further. More... | |
BaseFloat | FinalRelativeCost () const |
FinalRelativeCost() serves the same purpose as ReachedFinal(), but gives more information. More... | |
int32 | NumFramesDecoded () const |
LatticeFasterOnlineDecoderTpl is as LatticeFasterDecoderTpl 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 LatticeFasterDecoderTpl with Token == BackpointerToken if you do so indirectly via this child class.
Definition at line 54 of file lattice-faster-online-decoder.h.
using Arc = typename FST::Arc |
Definition at line 57 of file lattice-faster-online-decoder.h.
using ForwardLinkT = decoder::ForwardLink<Token> |
Definition at line 62 of file lattice-faster-online-decoder.h.
using Label = typename Arc::Label |
Definition at line 58 of file lattice-faster-online-decoder.h.
using StateId = typename Arc::StateId |
Definition at line 59 of file lattice-faster-online-decoder.h.
using Token = decoder::BackpointerToken |
Definition at line 61 of file lattice-faster-online-decoder.h.
using Weight = typename Arc::Weight |
Definition at line 60 of file lattice-faster-online-decoder.h.
|
inline |
Definition at line 67 of file lattice-faster-online-decoder.h.
|
inline |
Definition at line 73 of file lattice-faster-online-decoder.h.
LatticeFasterOnlineDecoderTpl< 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 78 of file lattice-faster-online-decoder.cc.
Referenced by OnlineSilenceWeighting::ComputeCurrentTraceback(), and LatticeFasterOnlineDecoderTpl< 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 56 of file lattice-faster-online-decoder.cc.
Referenced by LatticeFasterOnlineDecoderTpl< FST >::BestPathIterator::Done(), SingleUtteranceNnet2Decoder::GetBestPath(), SingleUtteranceGmmDecoder::GetBestPath(), and SingleUtteranceNnet2DecoderThreaded::GetBestPath().
Behaves the same as GetRawLattice but only processes tokens whose extra_cost is smaller than the best-cost plus the specified beam.
It is only worthwhile to call this function if beam is less than the lattice_beam specified in the config; otherwise, it would return essentially the same thing as GetRawLattice, but more slowly.
Definition at line 168 of file lattice-faster-online-decoder.cc.
Referenced by LatticeFasterOnlineDecoderTpl< FST >::BestPathIterator::Done(), and SingleUtteranceGmmDecoder::GetGaussianPosteriors().
KALDI_DISALLOW_COPY_AND_ASSIGN | ( | LatticeFasterOnlineDecoderTpl< FST > | ) |
This function does a self-test of GetBestPath().
Returns true on success; returns false and prints a warning on failure.
Definition at line 33 of file lattice-faster-online-decoder.cc.
Referenced by LatticeFasterOnlineDecoderTpl< FST >::BestPathIterator::Done().
LatticeFasterOnlineDecoderTpl< 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 132 of file lattice-faster-online-decoder.cc.
Referenced by OnlineSilenceWeighting::ComputeCurrentTraceback(), and LatticeFasterOnlineDecoderTpl< FST >::BestPathIterator::Done().