23 #ifndef KALDI_DECODER_LATTICE_FASTER_DECODER_H_ 24 #define KALDI_DECODER_LATTICE_FASTER_DECODER_H_ 29 #include "fst/fstlib.h" 59 max_active(std::numeric_limits<
int32>::max()),
63 determinize_lattice(true),
69 opts->
Register(
"beam", &beam,
"Decoding beam. Larger->slower, more accurate.");
70 opts->
Register(
"max-active", &max_active,
"Decoder max active states. Larger->slower; " 72 opts->
Register(
"min-active", &min_active,
"Decoder minimum #active states.");
73 opts->
Register(
"lattice-beam", &lattice_beam,
"Lattice generation beam. Larger->slower, " 74 "and deeper lattices");
75 opts->
Register(
"prune-interval", &prune_interval,
"Interval (in frames) at " 76 "which to prune tokens");
77 opts->
Register(
"determinize-lattice", &determinize_lattice,
"If true, " 78 "determinize the lattice (lattice-determinization, keeping only " 79 "best pdf-sequence for each word-sequence).");
80 opts->
Register(
"beam-delta", &beam_delta,
"Increment used in decoding-- this " 81 "parameter is obscure and relates to a speedup in the way the " 82 "max-active constraint is applied. Larger is more accurate.");
83 opts->
Register(
"hash-ratio", &hash_ratio,
"Setting used in decoder to " 84 "control hash behavior");
87 KALDI_ASSERT(beam > 0.0 && max_active > 1 && lattice_beam > 0.0
88 && min_active <= max_active
89 && prune_interval > 0 && beam_delta > 0.0 && hash_ratio >= 1.0
90 && prune_scale > 0.0 && prune_scale < 1.0);
104 template <
typename Token>
118 next_tok(next_tok), ilabel(ilabel), olabel(olabel),
119 graph_cost(graph_cost), acoustic_cost(acoustic_cost),
162 tot_cost(tot_cost), extra_cost(extra_cost), links(links), next(next) { }
201 this->backpointer = backpointer;
206 tot_cost(tot_cost), extra_cost(extra_cost), links(links), next(next),
207 backpointer(backpointer) { }
228 template <
typename FST,
typename Token = decoder::StdToken>
268 return FinalRelativeCost() != std::numeric_limits<BaseFloat>::infinity();
277 bool GetBestPath(
Lattice *ofst,
278 bool use_final_probs =
true)
const;
291 bool GetRawLattice(
Lattice *ofst,
bool use_final_probs =
true)
const;
303 bool use_final_probs =
true)
const;
316 int32 max_num_frames = -1);
325 void FinalizeDecoding();
348 inline static void DeleteForwardLinks(Token *tok);
356 TokenList(): toks(NULL), must_prune_forward_links(true),
357 must_prune_tokens(true) { }
368 void PossiblyResizeHash(
size_t num_toks);
393 void PruneForwardLinks(
int32 frame_plus_one,
bool *extra_costs_changed,
413 void ComputeFinalCosts(unordered_map<Token*, BaseFloat> *final_costs,
420 void PruneForwardLinksFinal();
426 void PruneTokensForFrame(
int32 frame_plus_one);
450 void ProcessNonemitting(
BaseFloat cost_cutoff);
506 void DeleteElems(
Elem *list);
514 static void TopSortTokens(Token *tok_list,
515 std::vector<Token*> *topsorted_list);
517 void ClearActiveTokens();
fst::StdArc::StateId StateId
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
void Register(kaldi::OptionsItf *opts)
void SetOptions(const LatticeFasterDecoderConfig &config)
void SetBackpointer(Token *backpointer)
const LatticeFasterDecoderConfig & GetOptions() const
DecodableInterface provides a link between the (acoustic-modeling and feature-processing) code and th...
typename fst::StdFst ::Arc Arc
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
bool ReachedFinal() const
says whether a final-state was active on the last frame.
LatticeFasterDecoderConfig config_
typename Arc::Weight Weight
StdToken(BaseFloat tot_cost, BaseFloat extra_cost, ForwardLinkT *links, Token *next, Token *backpointer)
#define KALDI_DISALLOW_COPY_AND_ASSIGN(type)
typename Arc::Label Label
ForwardLink(Token *next_tok, Label ilabel, Label olabel, BaseFloat graph_cost, BaseFloat acoustic_cost, ForwardLink *next)
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
void SetBackpointer(Token *backpointer)
std::vector< const Elem *> queue_
BaseFloat final_relative_cost_
unordered_map< Token *, BaseFloat > final_costs_
For the meaning of the next 3 variables, see the comment for decoding_finalized_ above., and ComputeFinalCosts().
int32 NumFramesDecoded() const
fst::VectorFst< LatticeArc > Lattice
bool must_prune_forward_links
std::vector< TokenList > active_toks_
fst::VectorFst< CompactLatticeArc > CompactLattice
fst::StdArc::Weight Weight
fst::DeterminizeLatticePhonePrunedOptions det_opts
This is the "normal" lattice-generating decoder.
std::vector< BaseFloat > tmp_array_
#define KALDI_ASSERT(cond)
LatticeFasterDecoderConfig()
LatticeFasterDecoderTpl< fst::StdFst, decoder::StdToken > LatticeFasterDecoder
bool decoding_finalized_
decoding_finalized_ is true if someone called FinalizeDecoding().
BackpointerToken(BaseFloat tot_cost, BaseFloat extra_cost, ForwardLinkT *links, Token *next, Token *backpointer)
typename HashList< StateId, decoder::BackpointerToken *>::Elem Elem
std::vector< BaseFloat > cost_offsets_
void Register(OptionsItf *opts)
BaseFloat final_best_cost_
HashList< StateId, Token * > toks_
typename Arc::StateId StateId