online-nnet3-incremental-decoding.cc
Go to the documentation of this file.
1 // online2/online-nnet3-incremental-decoding.cc
2 
3 // Copyright 2019 Zhehuai Chen
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 
21 #include "lat/lattice-functions.h"
23 #include "decoder/grammar-fst.h"
24 
25 namespace kaldi {
26 
27 template <typename FST>
29  const LatticeIncrementalDecoderConfig &decoder_opts,
30  const TransitionModel &trans_model,
32  const FST &fst,
33  OnlineNnet2FeaturePipeline *features):
34  decoder_opts_(decoder_opts),
35  input_feature_frame_shift_in_seconds_(features->FrameShiftInSeconds()),
36  trans_model_(trans_model),
37  decodable_(trans_model_, info,
38  features->InputFeature(), features->IvectorFeature()),
39  decoder_(fst, trans_model, decoder_opts_) {
40  decoder_.InitDecoding();
41 }
42 
43 template <typename FST>
45  decoder_.InitDecoding();
46  decodable_.SetFrameOffset(frame_offset);
47 }
48 
49 template <typename FST>
51  decoder_.AdvanceDecoding(&decodable_);
52 }
53 
54 template <typename FST>
56  Lattice *best_path) const {
57  decoder_.GetBestPath(best_path, end_of_utterance);
58 }
59 
60 template <typename FST>
62  const OnlineEndpointConfig &config) {
63  BaseFloat output_frame_shift =
67  output_frame_shift, decoder_);
68 }
69 
70 
71 // Instantiate the template for the types needed.
74 
75 } // namespace kaldi
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
SingleUtteranceNnet3IncrementalDecoderTpl(const LatticeIncrementalDecoderConfig &decoder_opts, const TransitionModel &trans_model, const nnet3::DecodableNnetSimpleLoopedInfo &info, const FST &fst, OnlineNnet2FeaturePipeline *features)
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
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...
void InitDecoding(int32 frame_offset=0)
Initializes the decoding and sets the frame offset of the underlying decodable object.
void AdvanceDecoding()
Advances the decoding as far as we can.
fst::VectorFst< LatticeArc > Lattice
Definition: kaldi-lattice.h:44
The normal decoder, lattice-faster-decoder.h, sometimes has an issue when doing real-time application...
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 ...
OnlineNnet2FeaturePipeline is a class that&#39;s responsible for putting together the various parts of th...
When you instantiate class DecodableNnetSimpleLooped, you should give it a const reference to this cl...
void GetBestPath(bool end_of_utterance, Lattice *best_path) const
Outputs an FST corresponding to the single best path through the current lattice. ...
void SetFrameOffset(int32 frame_offset)
Sets the frame offset value.