online-nnet3-decoding.h
Go to the documentation of this file.
1 // online2/online-nnet3-decoding.h
2 
3 // Copyright 2014 Johns Hopkins University (author: Daniel Povey)
4 // 2016 Api.ai (Author: Ilya Platonov)
5 
6 // See ../../COPYING for clarification regarding multiple authors
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 // MERCHANTABLITY OR NON-INFRINGEMENT.
18 // See the Apache 2 License for the specific language governing permissions and
19 // limitations under the License.
20 
21 
22 #ifndef KALDI_ONLINE2_ONLINE_NNET3_DECODING_H_
23 #define KALDI_ONLINE2_ONLINE_NNET3_DECODING_H_
24 
25 #include <string>
26 #include <vector>
27 #include <deque>
28 
30 #include "matrix/matrix-lib.h"
31 #include "util/common-utils.h"
32 #include "base/kaldi-error.h"
33 #include "itf/online-feature-itf.h"
37 #include "hmm/transition-model.h"
38 #include "hmm/posterior.h"
39 
40 namespace kaldi {
43 
44 
51 template <typename FST>
53  public:
54 
55  // Constructor. The pointer 'features' is not being given to this class to own
56  // and deallocate, it is owned externally.
58  const TransitionModel &trans_model,
60  const FST &fst,
61  OnlineNnet2FeaturePipeline *features);
62 
67  void InitDecoding(int32 frame_offset = 0);
68 
70  void AdvanceDecoding();
71 
75  void FinalizeDecoding();
76 
77  int32 NumFramesDecoded() const;
78 
84  void GetLattice(bool end_of_utterance,
85  CompactLattice *clat) const;
86 
91  void GetBestPath(bool end_of_utterance,
92  Lattice *best_path) const;
93 
94 
97  bool EndpointDetected(const OnlineEndpointConfig &config);
98 
100 
102  private:
103 
105 
106  // this is remembered from the constructor; it's ultimately
107  // derived from calling FrameShiftInSeconds() on the feature pipeline.
109 
110  // we need to keep a reference to the transition model around only because
111  // it's needed by the endpointing code.
113 
115 
117 
118 };
119 
120 
122 
124 
125 } // namespace kaldi
126 
127 
128 
129 #endif // KALDI_ONLINE2_ONLINE_NNET3_DECODING_H_
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
For an extended explanation of the framework of which grammar-fsts are a part, please see Support for...
Definition: graph.dox:21
kaldi::int32 int32
This file contains a different version of the feature-extraction pipeline in online-feature-pipeline...
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.
const LatticeFasterDecoderConfig & decoder_opts_
void GetLattice(bool end_of_utterance, CompactLattice *clat) const
Gets the lattice.
bool EndpointDetected(const OnlineEndpointConfig &config)
This function calls EndpointDetected from online-endpoint.h, with the required arguments.
You will instantiate this class when you want to decode a single utterance using the online-decoding ...
fst::VectorFst< LatticeArc > Lattice
Definition: kaldi-lattice.h:44
LatticeFasterOnlineDecoderTpl is as LatticeFasterDecoderTpl but also supports an efficient way to get...
fst::VectorFst< CompactLatticeArc > CompactLattice
Definition: kaldi-lattice.h:46
void GetBestPath(bool end_of_utterance, Lattice *best_path) const
Outputs an FST corresponding to the single best path through the current lattice. ...
nnet3::DecodableAmNnetLoopedOnline decodable_
LatticeFasterOnlineDecoderTpl< FST > decoder_
OnlineNnet2FeaturePipeline is a class that&#39;s responsible for putting together the various parts of th...
SingleUtteranceNnet3DecoderTpl< fst::Fst< fst::StdArc > > SingleUtteranceNnet3Decoder
void AdvanceDecoding()
Advances the decoding as far as we can.
When you instantiate class DecodableNnetSimpleLooped, you should give it a const reference to this cl...
const LatticeFasterOnlineDecoderTpl< FST > & Decoder() const
void FinalizeDecoding()
Finalizes the decoding.