SingleUtteranceNnet3IncrementalDecoderTpl< FST > Class Template Reference

You will instantiate this class when you want to decode a single utterance using the online-decoding setup for neural nets. More...

#include <online-nnet3-incremental-decoding.h>

Collaboration diagram for SingleUtteranceNnet3IncrementalDecoderTpl< FST >:

Public Member Functions

 SingleUtteranceNnet3IncrementalDecoderTpl (const LatticeIncrementalDecoderConfig &decoder_opts, const TransitionModel &trans_model, const nnet3::DecodableNnetSimpleLoopedInfo &info, const FST &fst, OnlineNnet2FeaturePipeline *features)
 
void InitDecoding (int32 frame_offset=0)
 Initializes the decoding and sets the frame offset of the underlying decodable object. More...
 
void AdvanceDecoding ()
 Advances the decoding as far as we can. More...
 
void FinalizeDecoding ()
 Finalizes the decoding. More...
 
int32 NumFramesDecoded () const
 
int32 NumFramesInLattice () const
 
const CompactLatticeGetLattice (int32 num_frames_to_include, bool use_final_probs=false)
 
void GetBestPath (bool end_of_utterance, Lattice *best_path) const
 Outputs an FST corresponding to the single best path through the current lattice. More...
 
bool EndpointDetected (const OnlineEndpointConfig &config)
 This function calls EndpointDetected from online-endpoint.h, with the required arguments. More...
 
const LatticeIncrementalOnlineDecoderTpl< FST > & Decoder () const
 
 ~SingleUtteranceNnet3IncrementalDecoderTpl ()
 

Private Attributes

const LatticeIncrementalDecoderConfigdecoder_opts_
 
BaseFloat input_feature_frame_shift_in_seconds_
 
const TransitionModeltrans_model_
 
nnet3::DecodableAmNnetLoopedOnline decodable_
 
LatticeIncrementalOnlineDecoderTpl< FST > decoder_
 

Detailed Description

template<typename FST>
class kaldi::SingleUtteranceNnet3IncrementalDecoderTpl< FST >

You will instantiate this class when you want to decode a single utterance using the online-decoding setup for neural nets.

The template will be instantiated only for FST = fst::Fst<fst::StdArc> and FST = fst::GrammarFst.

Definition at line 51 of file online-nnet3-incremental-decoding.h.

Constructor & Destructor Documentation

◆ SingleUtteranceNnet3IncrementalDecoderTpl()

SingleUtteranceNnet3IncrementalDecoderTpl ( const LatticeIncrementalDecoderConfig decoder_opts,
const TransitionModel trans_model,
const nnet3::DecodableNnetSimpleLoopedInfo info,
const FST &  fst,
OnlineNnet2FeaturePipeline features 
)

Definition at line 28 of file online-nnet3-incremental-decoding.cc.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

33  :
34  decoder_opts_(decoder_opts),
35  input_feature_frame_shift_in_seconds_(features->FrameShiftInSeconds()),
36  trans_model_(trans_model),
38  features->InputFeature(), features->IvectorFeature()),
39  decoder_(fst, trans_model, decoder_opts_) {
40  decoder_.InitDecoding();
41 }
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21

◆ ~SingleUtteranceNnet3IncrementalDecoderTpl()

Definition at line 120 of file online-nnet3-incremental-decoding.h.

120 { }

Member Function Documentation

◆ AdvanceDecoding()

void AdvanceDecoding ( )

Advances the decoding as far as we can.

Definition at line 50 of file online-nnet3-incremental-decoding.cc.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decodable_, and SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

Referenced by main().

50  {
51  decoder_.AdvanceDecoding(&decodable_);
52 }

◆ Decoder()

const LatticeIncrementalOnlineDecoderTpl<FST>& Decoder ( ) const
inline

Definition at line 118 of file online-nnet3-incremental-decoding.h.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

Referenced by main().

118 { return decoder_; }

◆ EndpointDetected()

bool EndpointDetected ( const OnlineEndpointConfig config)

This function calls EndpointDetected from online-endpoint.h, with the required arguments.

Definition at line 61 of file online-nnet3-incremental-decoding.cc.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decodable_, SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_, kaldi::EndpointDetected(), DecodableNnetLoopedOnlineBase::FrameSubsamplingFactor(), SingleUtteranceNnet3IncrementalDecoderTpl< FST >::input_feature_frame_shift_in_seconds_, and SingleUtteranceNnet3IncrementalDecoderTpl< FST >::trans_model_.

Referenced by SingleUtteranceNnet3IncrementalDecoderTpl< FST >::GetLattice(), and main().

62  {
63  BaseFloat output_frame_shift =
67  output_frame_shift, decoder_);
68 }
bool EndpointDetected(const OnlineEndpointConfig &config, int32 num_frames_decoded, int32 trailing_silence_frames, BaseFloat frame_shift_in_seconds, BaseFloat final_relative_cost)
This function returns true if this set of endpointing rules thinks we should terminate decoding...
float BaseFloat
Definition: kaldi-types.h:29

◆ FinalizeDecoding()

void FinalizeDecoding ( )
inline

Finalizes the decoding.

Cleans up and prunes remaining tokens, so the GetLattice() call will return faster. You must not call this before calling (TerminateDecoding() or InputIsFinished()) and then Wait().

Definition at line 74 of file online-nnet3-incremental-decoding.h.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

Referenced by main().

74 { decoder_.FinalizeDecoding(); }

◆ GetBestPath()

void GetBestPath ( bool  end_of_utterance,
Lattice best_path 
) const

Outputs an FST corresponding to the single best path through the current lattice.

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 55 of file online-nnet3-incremental-decoding.cc.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

Referenced by SingleUtteranceNnet3IncrementalDecoderTpl< FST >::GetLattice().

56  {
57  decoder_.GetBestPath(best_path, end_of_utterance);
58 }

◆ GetLattice()

const CompactLattice& GetLattice ( int32  num_frames_to_include,
bool  use_final_probs = false 
)
inline

◆ InitDecoding()

void InitDecoding ( int32  frame_offset = 0)

Initializes the decoding and sets the frame offset of the underlying decodable object.

This method is called by the constructor. You can also call this method when you want to reset the decoder state, but want to keep using the same decodable object, e.g. in case of an endpoint.

Definition at line 44 of file online-nnet3-incremental-decoding.cc.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decodable_, SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_, and DecodableNnetLoopedOnlineBase::SetFrameOffset().

44  {
45  decoder_.InitDecoding();
46  decodable_.SetFrameOffset(frame_offset);
47 }
void SetFrameOffset(int32 frame_offset)
Sets the frame offset value.

◆ NumFramesDecoded()

int32 NumFramesDecoded ( ) const
inline

Definition at line 76 of file online-nnet3-incremental-decoding.h.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

Referenced by main().

76 { return decoder_.NumFramesDecoded(); }

◆ NumFramesInLattice()

int32 NumFramesInLattice ( ) const
inline

Definition at line 78 of file online-nnet3-incremental-decoding.h.

References SingleUtteranceNnet3IncrementalDecoderTpl< FST >::decoder_.

78 { return decoder_.NumFramesInLattice(); }

Member Data Documentation

◆ decodable_

◆ decoder_

◆ decoder_opts_

const LatticeIncrementalDecoderConfig& decoder_opts_
private

Definition at line 123 of file online-nnet3-incremental-decoding.h.

◆ input_feature_frame_shift_in_seconds_

BaseFloat input_feature_frame_shift_in_seconds_
private

◆ trans_model_


The documentation for this class was generated from the following files: