#include <online-faster-decoder.h>
Public Types | |
enum | DecodeState { kEndFeats = 1, kEndUtt = 2, kEndBatch = 4 } |
Public Types inherited from FasterDecoder | |
typedef fst::StdArc | Arc |
typedef Arc::Label | Label |
typedef Arc::StateId | StateId |
typedef Arc::Weight | Weight |
Public Member Functions | |
OnlineFasterDecoder (const fst::Fst< fst::StdArc > &fst, const OnlineFasterDecoderOpts &opts, const std::vector< int32 > &sil_phones, const TransitionModel &trans_model) | |
DecodeState | Decode (DecodableInterface *decodable) |
bool | PartialTraceback (fst::MutableFst< LatticeArc > *out_fst) |
void | FinishTraceBack (fst::MutableFst< LatticeArc > *fst_out) |
bool | EndOfUtterance () |
int32 | frame () |
Public Member Functions inherited from FasterDecoder | |
FasterDecoder (const fst::Fst< fst::StdArc > &fst, const FasterDecoderOptions &config) | |
void | SetOptions (const FasterDecoderOptions &config) |
~FasterDecoder () | |
void | Decode (DecodableInterface *decodable) |
bool | ReachedFinal () const |
Returns true if a final state was active on the last frame. More... | |
bool | GetBestPath (fst::MutableFst< LatticeArc > *fst_out, bool use_final_probs=true) |
GetBestPath gets the decoding traceback. More... | |
void | InitDecoding () |
As a new alternative to Decode(), you can call InitDecoding and then (possibly multiple times) 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, but if max_num_frames is >= 0 it will decode no more than that many frames. More... | |
int32 | NumFramesDecoded () const |
Returns the number of frames already decoded. More... | |
Private Member Functions | |
void | ResetDecoder (bool full) |
void | TracebackNFrames (int32 nframes, fst::MutableFst< LatticeArc > *out_fst) |
void | MakeLattice (const Token *start, const Token *end, fst::MutableFst< LatticeArc > *out_fst) const |
void | UpdateImmortalToken () |
KALDI_DISALLOW_COPY_AND_ASSIGN (OnlineFasterDecoder) | |
Private Attributes | |
const OnlineFasterDecoderOpts | opts_ |
const ConstIntegerSet< int32 > | silence_set_ |
const TransitionModel & | trans_model_ |
const BaseFloat | max_beam_ |
BaseFloat & | effective_beam_ |
DecodeState | state_ |
int32 | frame_ |
int32 | utt_frames_ |
Token * | immortal_tok_ |
Token * | prev_immortal_tok_ |
Additional Inherited Members | |
Protected Types inherited from FasterDecoder | |
typedef HashList< StateId, Token * >::Elem | Elem |
Protected Member Functions inherited from FasterDecoder | |
double | GetCutoff (Elem *list_head, size_t *tok_count, BaseFloat *adaptive_beam, Elem **best_elem) |
Gets the weight cutoff. Also counts the active tokens. More... | |
void | PossiblyResizeHash (size_t num_toks) |
double | ProcessEmitting (DecodableInterface *decodable) |
void | ProcessNonemitting (double cutoff) |
void | ClearToks (Elem *list) |
KALDI_DISALLOW_COPY_AND_ASSIGN (FasterDecoder) | |
Protected Attributes inherited from FasterDecoder | |
HashList< StateId, Token * > | toks_ |
const fst::Fst< fst::StdArc > & | fst_ |
FasterDecoderOptions | config_ |
std::vector< const Elem *> | queue_ |
std::vector< BaseFloat > | tmp_array_ |
int32 | num_frames_decoded_ |
Definition at line 69 of file online-faster-decoder.h.
enum DecodeState |
|
inline |
Definition at line 79 of file online-faster-decoder.h.
OnlineFasterDecoder::DecodeState Decode | ( | DecodableInterface * | decodable | ) |
Definition at line 231 of file online-faster-decoder.cc.
References OnlineFasterDecoderOpts::batch_size, OnlineFasterDecoderOpts::beam_update, OnlineFasterDecoder::effective_beam_, Timer::Elapsed(), OnlineFasterDecoder::EndOfUtterance(), OnlineFasterDecoder::frame_, DecodableInterface::IsLastFrame(), KALDI_VLOG, OnlineFasterDecoder::kEndBatch, OnlineFasterDecoder::kEndFeats, OnlineFasterDecoder::kEndUtt, OnlineFasterDecoder::max_beam_, OnlineFasterDecoderOpts::max_beam_update, OnlineFasterDecoder::opts_, FasterDecoder::ProcessEmitting(), FasterDecoder::ProcessNonemitting(), OnlineFasterDecoder::ResetDecoder(), OnlineFasterDecoderOpts::rt_max, OnlineFasterDecoderOpts::rt_min, OnlineFasterDecoder::state_, OnlineFasterDecoderOpts::update_interval, and OnlineFasterDecoder::utt_frames_.
Referenced by main().
bool EndOfUtterance | ( | ) |
Definition at line 210 of file online-faster-decoder.cc.
References ConstIntegerSet< I >::count(), fst::GetLinearSymbolSequence(), rnnlm::i, OnlineFasterDecoderOpts::inter_utt_sil, OnlineFasterDecoderOpts::max_utt_len_, OnlineFasterDecoder::opts_, OnlineFasterDecoder::silence_set_, kaldi::SplitToPhones(), OnlineFasterDecoder::TracebackNFrames(), OnlineFasterDecoder::trans_model_, TransitionModel::TransitionIdToPhone(), and OnlineFasterDecoder::utt_frames_.
Referenced by OnlineFasterDecoder::Decode().
void FinishTraceBack | ( | fst::MutableFst< LatticeArc > * | fst_out | ) |
Definition at line 136 of file online-faster-decoder.cc.
References FasterDecoder::fst_, HashList< I, T >::GetList(), OnlineFasterDecoder::immortal_tok_, OnlineFasterDecoder::MakeLattice(), FasterDecoder::ReachedFinal(), HashList< I, T >::Elem::tail, and FasterDecoder::toks_.
Referenced by main().
|
inline |
Definition at line 102 of file online-faster-decoder.h.
References kaldi::full.
Referenced by main().
|
private |
|
private |
Definition at line 45 of file online-faster-decoder.cc.
References FasterDecoder::Token::arc_, FasterDecoder::Token::cost_, FasterDecoder::fst_, rnnlm::i, LatticeWeightTpl< BaseFloat >::One(), FasterDecoder::Token::prev_, and fst::RemoveEpsLocal().
Referenced by OnlineFasterDecoder::FinishTraceBack(), and OnlineFasterDecoder::PartialTraceback().
bool PartialTraceback | ( | fst::MutableFst< LatticeArc > * | out_fst | ) |
Definition at line 126 of file online-faster-decoder.cc.
References OnlineFasterDecoder::immortal_tok_, OnlineFasterDecoder::MakeLattice(), OnlineFasterDecoder::prev_immortal_tok_, and OnlineFasterDecoder::UpdateImmortalToken().
Referenced by main().
|
private |
Definition at line 30 of file online-faster-decoder.cc.
References HashList< I, T >::Clear(), FasterDecoder::ClearToks(), OnlineFasterDecoder::frame_, FasterDecoder::fst_, OnlineFasterDecoder::immortal_tok_, HashList< I, T >::Insert(), KALDI_ASSERT, OnlineFasterDecoder::prev_immortal_tok_, FasterDecoder::toks_, and OnlineFasterDecoder::utt_frames_.
Referenced by OnlineFasterDecoder::Decode().
|
private |
Definition at line 159 of file online-faster-decoder.cc.
References FasterDecoder::Token::arc_, FasterDecoder::Token::cost_, FasterDecoder::fst_, HashList< I, T >::GetList(), rnnlm::i, LatticeWeightTpl< BaseFloat >::One(), FasterDecoder::Token::prev_, fst::RemoveEpsLocal(), HashList< I, T >::Elem::tail, and FasterDecoder::toks_.
Referenced by OnlineFasterDecoder::EndOfUtterance().
|
private |
Definition at line 87 of file online-faster-decoder.cc.
References FasterDecoder::Token::arc_, HashList< I, T >::GetList(), OnlineFasterDecoder::immortal_tok_, FasterDecoder::Token::prev_, OnlineFasterDecoder::prev_immortal_tok_, HashList< I, T >::Elem::tail, and FasterDecoder::toks_.
Referenced by OnlineFasterDecoder::PartialTraceback().
|
private |
Definition at line 123 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::Decode().
|
private |
Definition at line 125 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::Decode(), and OnlineFasterDecoder::ResetDecoder().
|
private |
Definition at line 127 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::FinishTraceBack(), OnlineFasterDecoder::PartialTraceback(), OnlineFasterDecoder::ResetDecoder(), and OnlineFasterDecoder::UpdateImmortalToken().
|
private |
Definition at line 122 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::Decode().
|
private |
Definition at line 119 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::Decode(), and OnlineFasterDecoder::EndOfUtterance().
|
private |
Definition at line 128 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::PartialTraceback(), OnlineFasterDecoder::ResetDecoder(), and OnlineFasterDecoder::UpdateImmortalToken().
|
private |
Definition at line 120 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::EndOfUtterance().
|
private |
Definition at line 124 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::Decode().
|
private |
Definition at line 121 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::EndOfUtterance().
|
private |
Definition at line 126 of file online-faster-decoder.h.
Referenced by OnlineFasterDecoder::Decode(), OnlineFasterDecoder::EndOfUtterance(), and OnlineFasterDecoder::ResetDecoder().