SingleUtteranceNnet3DecoderTpl< 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-decoding.h>

Collaboration diagram for SingleUtteranceNnet3DecoderTpl< FST >:

Public Member Functions

 SingleUtteranceNnet3DecoderTpl (const LatticeFasterDecoderConfig &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
 
void GetLattice (bool end_of_utterance, CompactLattice *clat) const
 Gets the lattice. More...
 
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 LatticeFasterOnlineDecoderTpl< FST > & Decoder () const
 
 ~SingleUtteranceNnet3DecoderTpl ()
 

Private Attributes

const LatticeFasterDecoderConfigdecoder_opts_
 
BaseFloat input_feature_frame_shift_in_seconds_
 
const TransitionModeltrans_model_
 
nnet3::DecodableAmNnetLoopedOnline decodable_
 
LatticeFasterOnlineDecoderTpl< FST > decoder_
 

Detailed Description

template<typename FST>
class kaldi::SingleUtteranceNnet3DecoderTpl< 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 52 of file online-nnet3-decoding.h.

Constructor & Destructor Documentation

◆ SingleUtteranceNnet3DecoderTpl()

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

Definition at line 29 of file online-nnet3-decoding.cc.

References SingleUtteranceNnet3DecoderTpl< FST >::decoder_.

34  :
35  decoder_opts_(decoder_opts),
36  input_feature_frame_shift_in_seconds_(features->FrameShiftInSeconds()),
37  trans_model_(trans_model),
39  features->InputFeature(), features->IvectorFeature()),
41  decoder_.InitDecoding();
42 }
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21
const LatticeFasterDecoderConfig & decoder_opts_
nnet3::DecodableAmNnetLoopedOnline decodable_
LatticeFasterOnlineDecoderTpl< FST > decoder_

◆ ~SingleUtteranceNnet3DecoderTpl()

Definition at line 101 of file online-nnet3-decoding.h.

101 { }

Member Function Documentation

◆ AdvanceDecoding()

void AdvanceDecoding ( )

Advances the decoding as far as we can.

Definition at line 51 of file online-nnet3-decoding.cc.

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

Referenced by main().

51  {
52  decoder_.AdvanceDecoding(&decodable_);
53 }
nnet3::DecodableAmNnetLoopedOnline decodable_
LatticeFasterOnlineDecoderTpl< FST > decoder_

◆ Decoder()

const LatticeFasterOnlineDecoderTpl<FST>& Decoder ( ) const
inline

Definition at line 99 of file online-nnet3-decoding.h.

References SingleUtteranceNnet3DecoderTpl< FST >::decoder_.

Referenced by main().

99 { return decoder_; }
LatticeFasterOnlineDecoderTpl< FST > decoder_

◆ EndpointDetected()

bool EndpointDetected ( const OnlineEndpointConfig config)

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

Definition at line 88 of file online-nnet3-decoding.cc.

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

Referenced by main().

89  {
90  BaseFloat output_frame_shift =
94  output_frame_shift, decoder_);
95 }
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
nnet3::DecodableAmNnetLoopedOnline decodable_
LatticeFasterOnlineDecoderTpl< FST > decoder_

◆ FinalizeDecoding()

void FinalizeDecoding ( )

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

References SingleUtteranceNnet3DecoderTpl< FST >::decoder_.

Referenced by main().

56  {
57  decoder_.FinalizeDecoding();
58 }
LatticeFasterOnlineDecoderTpl< FST > decoder_

◆ 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 82 of file online-nnet3-decoding.cc.

References SingleUtteranceNnet3DecoderTpl< FST >::decoder_.

Referenced by main().

83  {
84  decoder_.GetBestPath(best_path, end_of_utterance);
85 }
LatticeFasterOnlineDecoderTpl< FST > decoder_

◆ GetLattice()

void GetLattice ( bool  end_of_utterance,
CompactLattice clat 
) const

Gets the lattice.

The output lattice has any acoustic scaling in it (which will typically be desirable in an online-decoding context); if you want an un-scaled lattice, scale it using ScaleLattice() with the inverse of the acoustic weight. "end_of_utterance" will be true if you want the final-probs to be included.

Definition at line 66 of file online-nnet3-decoding.cc.

References SingleUtteranceNnet3DecoderTpl< FST >::decoder_, SingleUtteranceNnet3DecoderTpl< FST >::decoder_opts_, LatticeFasterDecoderConfig::det_opts, LatticeFasterDecoderConfig::determinize_lattice, fst::DeterminizeLatticePhonePrunedWrapper(), KALDI_ERR, LatticeFasterDecoderConfig::lattice_beam, SingleUtteranceNnet3DecoderTpl< FST >::NumFramesDecoded(), and SingleUtteranceNnet3DecoderTpl< FST >::trans_model_.

Referenced by main().

67  {
68  if (NumFramesDecoded() == 0)
69  KALDI_ERR << "You cannot get a lattice if you decoded no frames.";
70  Lattice raw_lat;
71  decoder_.GetRawLattice(&raw_lat, end_of_utterance);
72 
74  KALDI_ERR << "--determinize-lattice=false option is not supported at the moment";
75 
78  trans_model_, &raw_lat, lat_beam, clat, decoder_opts_.det_opts);
79 }
float BaseFloat
Definition: kaldi-types.h:29
const LatticeFasterDecoderConfig & decoder_opts_
fst::VectorFst< LatticeArc > Lattice
Definition: kaldi-lattice.h:44
#define KALDI_ERR
Definition: kaldi-error.h:147
fst::DeterminizeLatticePhonePrunedOptions det_opts
LatticeFasterOnlineDecoderTpl< FST > decoder_
bool DeterminizeLatticePhonePrunedWrapper(const kaldi::TransitionModel &trans_model, MutableFst< kaldi::LatticeArc > *ifst, double beam, MutableFst< kaldi::CompactLatticeArc > *ofst, DeterminizeLatticePhonePrunedOptions opts)
This function is a wrapper of DeterminizeLatticePhonePruned() that works for Lattice type FSTs...

◆ 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 45 of file online-nnet3-decoding.cc.

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

Referenced by main().

45  {
46  decoder_.InitDecoding();
47  decodable_.SetFrameOffset(frame_offset);
48 }
nnet3::DecodableAmNnetLoopedOnline decodable_
LatticeFasterOnlineDecoderTpl< FST > decoder_
void SetFrameOffset(int32 frame_offset)
Sets the frame offset value.

◆ NumFramesDecoded()

int32 NumFramesDecoded ( ) const

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

References SingleUtteranceNnet3DecoderTpl< FST >::decoder_.

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

61  {
62  return decoder_.NumFramesDecoded();
63 }
LatticeFasterOnlineDecoderTpl< FST > decoder_

Member Data Documentation

◆ decodable_

◆ decoder_

◆ decoder_opts_

const LatticeFasterDecoderConfig& decoder_opts_
private

◆ 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: