online-gmm-decodable.cc
Go to the documentation of this file.
1 // online2/online-gmm-decodable.cc
2 
3 // Copyright 2012 Cisco Systems (author: Matthias Paulik)
4 // 2013 Vassil Panayotov
5 // 2014 Johns Hopkins University (author: Daniel Povey)
6 
7 // See ../../COPYING for clarification regarding multiple authors
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
17 // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
18 // MERCHANTABLITY OR NON-INFRINGEMENT.
19 // See the Apache 2 License for the specific language governing permissions and
20 // limitations under the License.
21 
23 
24 namespace kaldi {
25 
27  const AmDiagGmm &am, const TransitionModel &trans_model,
28  const BaseFloat scale, OnlineFeatureInterface *input_feats):
29  features_(input_feats), ac_model_(am),
30  ac_scale_(scale), trans_model_(trans_model),
31  feat_dim_(input_feats->Dim()), cur_feats_(feat_dim_),
32  cur_frame_(-1) {
33  int32 num_pdfs = trans_model_.NumPdfs();
34  cache_.resize(num_pdfs, std::pair<int32,BaseFloat>(-1, 0.0f));
35 }
36 
38  // The call below will fail if "frame" is an invalid index, i.e. <0
39  // or >= features_->NumFramesReady(), so there
40  // is no need to check again.
41  features_->GetFrame(frame, &cur_feats_);
42  cur_frame_ = frame;
43 }
44 
46  if (frame != cur_frame_)
47  CacheFrame(frame);
48  int32 pdf_id = trans_model_.TransitionIdToPdf(index);
49  if (cache_[pdf_id].first == frame)
50  return cache_[pdf_id].second;
52  cache_[pdf_id].first = frame;
53  cache_[pdf_id].second = ans;
54  return ans;
55 }
56 
57 
59  return features_->IsLastFrame(frame);
60 }
61 
63  return features_->NumFramesReady();
64 }
65 
66 } // namespace kaldi
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Definition: chain.dox:20
DecodableDiagGmmScaledOnline(const AmDiagGmm &am, const TransitionModel &trans_model, const BaseFloat scale, OnlineFeatureInterface *input_feats)
virtual void GetFrame(int32 frame, VectorBase< BaseFloat > *feat)=0
Gets the feature vector for this frame.
kaldi::int32 int32
virtual int32 NumFramesReady() const
The call NumFramesReady() will return the number of frames currently available for this decodable obj...
int32 TransitionIdToPdf(int32 trans_id) const
BaseFloat LogLikelihood(const int32 pdf_index, const VectorBase< BaseFloat > &data) const
Definition: am-diag-gmm.h:108
virtual BaseFloat LogLikelihood(int32 frame, int32 index)
Returns the scaled log likelihood.
virtual bool IsLastFrame(int32 frame) const =0
Returns true if this is the last frame.
virtual bool IsLastFrame(int32 frame) const
Returns true if this is the last frame.
std::vector< std::pair< int32, BaseFloat > > cache_
OnlineFeatureInterface is an interface for online feature processing (it is also usable in the offlin...
virtual int32 NumFramesReady() const =0
returns the feature dimension.