SingleUtteranceNnet2Decoder Class 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-nnet2-decoding.h>

Collaboration diagram for SingleUtteranceNnet2Decoder:

Public Member Functions

 SingleUtteranceNnet2Decoder (const OnlineNnet2DecodingConfig &config, const TransitionModel &tmodel, const nnet2::AmNnet &model, const fst::Fst< fst::StdArc > &fst, OnlineFeatureInterface *feature_pipeline)
 
void AdvanceDecoding ()
 advance 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 LatticeFasterOnlineDecoderDecoder () const
 
 ~SingleUtteranceNnet2Decoder ()
 

Private Attributes

OnlineNnet2DecodingConfig config_
 
OnlineFeatureInterfacefeature_pipeline_
 
const TransitionModeltmodel_
 
nnet2::DecodableNnet2Online decodable_
 
LatticeFasterOnlineDecoder decoder_
 

Detailed Description

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

Definition at line 67 of file online-nnet2-decoding.h.

Constructor & Destructor Documentation

◆ SingleUtteranceNnet2Decoder()

SingleUtteranceNnet2Decoder ( const OnlineNnet2DecodingConfig config,
const TransitionModel tmodel,
const nnet2::AmNnet model,
const fst::Fst< fst::StdArc > &  fst,
OnlineFeatureInterface feature_pipeline 
)

Definition at line 26 of file online-nnet2-decoding.cc.

References SingleUtteranceNnet2Decoder::decoder_, and LatticeFasterDecoderTpl< FST, Token >::InitDecoding().

31  :
32  config_(config),
33  feature_pipeline_(feature_pipeline),
34  tmodel_(tmodel),
35  decodable_(model, tmodel, config.decodable_opts, feature_pipeline),
36  decoder_(fst, config.decoder_opts) {
38 }
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21
OnlineFeatureInterface * feature_pipeline_
void InitDecoding()
InitDecoding initializes the decoding, and should only be used if you intend to call AdvanceDecoding(...
nnet2::DecodableNnet2Online decodable_

◆ ~SingleUtteranceNnet2Decoder()

Definition at line 109 of file online-nnet2-decoding.h.

109 { }

Member Function Documentation

◆ AdvanceDecoding()

void AdvanceDecoding ( )

advance the decoding as far as we can.

Definition at line 40 of file online-nnet2-decoding.cc.

References LatticeFasterDecoderTpl< FST, Token >::AdvanceDecoding(), SingleUtteranceNnet2Decoder::decodable_, and SingleUtteranceNnet2Decoder::decoder_.

Referenced by main().

40  {
42 }
void AdvanceDecoding(DecodableInterface *decodable, int32 max_num_frames=-1)
This will decode until there are no more frames ready in the decodable object.
nnet2::DecodableNnet2Online decodable_

◆ Decoder()

const LatticeFasterOnlineDecoder& Decoder ( ) const
inline

Definition at line 107 of file online-nnet2-decoding.h.

Referenced by main().

107 { return decoder_; }

◆ EndpointDetected()

bool EndpointDetected ( const OnlineEndpointConfig config)

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

Definition at line 72 of file online-nnet2-decoding.cc.

References SingleUtteranceNnet2Decoder::decoder_, kaldi::EndpointDetected(), SingleUtteranceNnet2Decoder::feature_pipeline_, OnlineFeatureInterface::FrameShiftInSeconds(), and SingleUtteranceNnet2Decoder::tmodel_.

Referenced by main().

73  {
74  return kaldi::EndpointDetected(config, tmodel_,
76  decoder_);
77 }
OnlineFeatureInterface * feature_pipeline_
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...
virtual BaseFloat FrameShiftInSeconds() const =0

◆ 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 44 of file online-nnet2-decoding.cc.

References SingleUtteranceNnet2Decoder::decoder_, and LatticeFasterDecoderTpl< FST, Token >::FinalizeDecoding().

Referenced by main().

44  {
46 }
void FinalizeDecoding()
This function may be optionally called after AdvanceDecoding(), when you do not plan to decode any fu...

◆ 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 67 of file online-nnet2-decoding.cc.

References SingleUtteranceNnet2Decoder::decoder_, and LatticeFasterOnlineDecoderTpl< FST >::GetBestPath().

68  {
69  decoder_.GetBestPath(best_path, end_of_utterance);
70 }
bool GetBestPath(Lattice *ofst, bool use_final_probs=true) const
Outputs an FST corresponding to the single best path through the lattice.

◆ 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 52 of file online-nnet2-decoding.cc.

References SingleUtteranceNnet2Decoder::config_, SingleUtteranceNnet2Decoder::decoder_, OnlineNnet2DecodingConfig::decoder_opts, LatticeFasterDecoderConfig::det_opts, LatticeFasterDecoderConfig::determinize_lattice, fst::DeterminizeLatticePhonePrunedWrapper(), LatticeFasterDecoderTpl< FST, Token >::GetRawLattice(), KALDI_ERR, LatticeFasterDecoderConfig::lattice_beam, SingleUtteranceNnet2Decoder::NumFramesDecoded(), and SingleUtteranceNnet2Decoder::tmodel_.

Referenced by main().

53  {
54  if (NumFramesDecoded() == 0)
55  KALDI_ERR << "You cannot get a lattice if you decoded no frames.";
56  Lattice raw_lat;
57  decoder_.GetRawLattice(&raw_lat, end_of_utterance);
58 
60  KALDI_ERR << "--determinize-lattice=false option is not supported at the moment";
61 
64  tmodel_, &raw_lat, lat_beam, clat, config_.decoder_opts.det_opts);
65 }
bool GetRawLattice(Lattice *ofst, bool use_final_probs=true) const
Outputs an FST corresponding to the raw, state-level tracebacks.
float BaseFloat
Definition: kaldi-types.h:29
fst::VectorFst< LatticeArc > Lattice
Definition: kaldi-lattice.h:44
#define KALDI_ERR
Definition: kaldi-error.h:147
fst::DeterminizeLatticePhonePrunedOptions det_opts
LatticeFasterDecoderConfig decoder_opts
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...

◆ NumFramesDecoded()

Member Data Documentation

◆ config_

OnlineNnet2DecodingConfig config_
private

Definition at line 112 of file online-nnet2-decoding.h.

Referenced by SingleUtteranceNnet2Decoder::GetLattice().

◆ decodable_

nnet2::DecodableNnet2Online decodable_
private

◆ decoder_

◆ feature_pipeline_

OnlineFeatureInterface* feature_pipeline_
private

◆ tmodel_


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