online-nnet2-decoding.h
Go to the documentation of this file.
1 // online2/online-nnet2-decoding.h
2 
3 // Copyright 2014 Johns Hopkins University (author: Daniel Povey)
4 
5 // See ../../COPYING for clarification regarding multiple authors
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 // MERCHANTABLITY OR NON-INFRINGEMENT.
17 // See the Apache 2 License for the specific language governing permissions and
18 // limitations under the License.
19 
20 
21 #ifndef KALDI_ONLINE2_ONLINE_NNET2_DECODING_H_
22 #define KALDI_ONLINE2_ONLINE_NNET2_DECODING_H_
23 
24 #include <string>
25 #include <vector>
26 #include <deque>
27 
28 #include "matrix/matrix-lib.h"
29 #include "util/common-utils.h"
30 #include "base/kaldi-error.h"
32 #include "itf/online-feature-itf.h"
35 #include "hmm/transition-model.h"
36 #include "hmm/posterior.h"
37 
38 namespace kaldi {
41 
42 
43 
44 
45 
46 // This configuration class contains the configuration classes needed to create
47 // the class SingleUtteranceNnet2Decoder. The actual command line program
48 // requires other configs that it creates separately, and which are not included
49 // here: namely, OnlineNnet2FeaturePipelineConfig and OnlineEndpointConfig.
51 
54 
55  OnlineNnet2DecodingConfig() { decodable_opts.acoustic_scale = 0.1; }
56 
57  void Register(OptionsItf *opts) {
58  decoder_opts.Register(opts);
59  decodable_opts.Register(opts);
60  }
61 };
62 
68  public:
69  // Constructor. The feature_pipeline_ pointer is not owned in this
70  // class, it's owned externally.
72  const TransitionModel &tmodel,
73  const nnet2::AmNnet &model,
74  const fst::Fst<fst::StdArc> &fst,
75  OnlineFeatureInterface *feature_pipeline);
76 
78  void AdvanceDecoding();
79 
83  void FinalizeDecoding();
84 
85  int32 NumFramesDecoded() const;
86 
92  void GetLattice(bool end_of_utterance,
93  CompactLattice *clat) const;
94 
99  void GetBestPath(bool end_of_utterance,
100  Lattice *best_path) const;
101 
102 
105  bool EndpointDetected(const OnlineEndpointConfig &config);
106 
107  const LatticeFasterOnlineDecoder &Decoder() const { return decoder_; }
108 
110  private:
111 
113 
115 
117 
119 
121 
122 };
123 
124 
126 
127 } // namespace kaldi
128 
129 
130 
131 #endif // KALDI_ONLINE2_ONLINE_NNET2_DECODING_H_
nnet2::DecodableNnet2OnlineOptions decodable_opts
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
OnlineFeatureInterface * feature_pipeline_
const LatticeFasterOnlineDecoder & Decoder() const
kaldi::int32 int32
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...
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
This Decodable object for class nnet2::AmNnet takes feature input from class OnlineFeatureInterface, unlike, say, class DecodableAmNnet which takes feature input from a matrix.
fst::VectorFst< CompactLatticeArc > CompactLattice
Definition: kaldi-lattice.h:46
LatticeFasterDecoderConfig decoder_opts
OnlineFeatureInterface is an interface for online feature processing (it is also usable in the offlin...
nnet2::DecodableNnet2Online decodable_