22 #ifndef KALDI_DECODER_LATTICE_SIMPLE_DECODER_H_ 23 #define KALDI_DECODER_LATTICE_SIMPLE_DECODER_H_ 27 #include "fst/fstlib.h" 53 determinize_lattice(true),
58 opts->
Register(
"beam", &beam,
"Decoding beam.");
59 opts->
Register(
"lattice-beam", &lattice_beam,
"Lattice generation beam");
60 opts->
Register(
"prune-interval", &prune_interval,
"Interval (in frames) at " 61 "which to prune tokens");
62 opts->
Register(
"determinize-lattice", &determinize_lattice,
"If true, " 63 "determinize the lattice (in a special sense, keeping only " 64 "best pdf-sequence for each word-sequence).");
67 KALDI_ASSERT(beam > 0.0 && lattice_beam > 0.0 && prune_interval > 0);
85 fst_(fst), config_(config), num_toks_(0) { config.
Check(); }
101 return FinalRelativeCost() != std::numeric_limits<BaseFloat>::infinity();
122 void FinalizeDecoding();
141 bool use_final_probs =
true)
const;
149 bool GetRawLattice(
Lattice *lat,
150 bool use_final_probs =
true)
const;
158 bool use_final_probs =
true)
const;
176 next_tok(next_tok), ilabel(ilabel), olabel(olabel),
177 graph_cost(graph_cost), acoustic_cost(acoustic_cost),
199 Token *next): tot_cost(tot_cost), extra_cost(extra_cost), links(links),
219 TokenList(): toks(NULL), must_prune_forward_links(true),
220 must_prune_tokens(true) { }
231 inline Token *FindOrAddToken(StateId state,
int32 frame_plus_one,
232 BaseFloat tot_cost,
bool emitting,
bool *changed);
237 void PruneForwardLinks(
int32 frame,
bool *extra_costs_changed,
244 void PruneForwardLinksFinal();
249 void PruneTokensForFrame(
int32 frame);
262 void ProcessNonemitting();
264 void ClearActiveTokens();
279 void ComputeFinalCosts(unordered_map<Token*, BaseFloat> *final_costs,
287 void PruneCurrentTokens(
BaseFloat beam, unordered_map<StateId, Token*> *toks);
293 const fst::Fst<fst::StdArc> &
fst_;
fst::StdArc::StateId StateId
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
std::vector< TokenList > active_toks_
void Register(kaldi::OptionsItf *opts)
LatticeSimpleDecoderConfig config_
DecodableInterface provides a link between the (acoustic-modeling and feature-processing) code and th...
int32 NumFramesDecoded() const
BaseFloat final_relative_cost_
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
BaseFloat final_best_cost_
LatticeSimpleDecoder(const fst::Fst< fst::StdArc > &fst, const LatticeSimpleDecoderConfig &config)
bool decoding_finalized_
decoding_finalized_ is true if someone called FinalizeDecoding().
void Register(OptionsItf *opts)
const LatticeSimpleDecoderConfig & GetOptions() const
unordered_map< Token *, BaseFloat > final_costs_
For the meaning of the next 3 variables, see the comment for decoding_finalized_ above., and ComputeFinalCosts().
virtual void Register(const std::string &name, bool *ptr, const std::string &doc)=0
void DeleteForwardLinks()
unordered_map< StateId, Token * > prev_toks_
ForwardLink(Token *next_tok, Label ilabel, Label olabel, BaseFloat graph_cost, BaseFloat acoustic_cost, ForwardLink *next)
const fst::Fst< fst::StdArc > & fst_
Token(BaseFloat tot_cost, BaseFloat extra_cost, ForwardLink *links, Token *next)
fst::VectorFst< LatticeArc > Lattice
LatticeSimpleDecoderConfig()
Simplest possible decoder, included largely for didactic purposes and as a means to debug more highly...
fst::VectorFst< CompactLatticeArc > CompactLattice
fst::StdArc::Weight Weight
#define KALDI_ASSERT(cond)
bool ReachedFinal() const
says whether a final-state was active on the last frame.
unordered_map< StateId, Token * > cur_toks_
fst::DeterminizeLatticePhonePrunedOptions det_opts
bool must_prune_forward_links