OnlineFeaturePipeline is a class that's responsible for putting together the various stages of the feature-processing pipeline, in an online setting. More...
#include <online-feature-pipeline.h>
Public Member Functions | |
OnlineFeaturePipeline (const OnlineFeaturePipelineConfig &cfg) | |
virtual int32 | Dim () const |
Member functions from OnlineFeatureInterface: More... | |
virtual bool | IsLastFrame (int32 frame) const |
Returns true if this is the last frame. More... | |
virtual int32 | NumFramesReady () const |
returns the feature dimension. More... | |
virtual void | GetFrame (int32 frame, VectorBase< BaseFloat > *feat) |
Gets the feature vector for this frame. More... | |
void | GetAsMatrix (Matrix< BaseFloat > *feats) |
void | FreezeCmvn () |
void | SetCmvnState (const OnlineCmvnState &cmvn_state) |
Set the CMVN state to a particular value (will generally be called after Copy(). More... | |
void | GetCmvnState (OnlineCmvnState *cmvn_state) |
void | AcceptWaveform (BaseFloat sampling_rate, const VectorBase< BaseFloat > &waveform) |
Accept more data to process (won't actually process it, will just copy it). More... | |
BaseFloat | FrameShiftInSeconds () const |
void | InputFinished () |
void | SetTransform (const MatrixBase< BaseFloat > &transform) |
bool | HaveFmllrTransform () |
OnlineFeaturePipeline * | New () const |
returns a newly initialized copy of *this– this does not duplicate all the internal state or the speaker-adaptation state, but gives you a freshly initialized version of this object, as if you had initialized it using the constructor that takes the config file. More... | |
virtual | ~OnlineFeaturePipeline () |
Public Member Functions inherited from OnlineFeatureInterface | |
virtual void | GetFrames (const std::vector< int32 > &frames, MatrixBase< BaseFloat > *feats) |
This is like GetFrame() but for a collection of frames. More... | |
virtual | ~OnlineFeatureInterface () |
Virtual destructor. More... | |
Private Member Functions | |
OnlineFeaturePipeline (const OnlineFeaturePipelineConfig &cfg, const Matrix< BaseFloat > &lda_mat, const Matrix< BaseFloat > &global_cmvn_stats) | |
The following constructor is used internally in the New() function; it has the same effect as initializing from just "cfg", but avoids re-reading the LDA transform from disk. More... | |
void | Init () |
Init() is to be called from the constructor; it assumes the pointer members are all uninitialized but config_ and lda_mat_ are initialized. More... | |
OnlineFeatureInterface * | UnadaptedFeature () const |
returns lda_ if it exists, else splice_or_delta_, else cmvn_. More... | |
OnlineFeatureInterface * | AdaptedFeature () const |
returns adapted feature if fmllr_ exists, else UnadaptedFeature(). More... | |
OnlineFeaturePipeline is a class that's responsible for putting together the various stages of the feature-processing pipeline, in an online setting.
This does not attempt to be fully generic, we just try to handle the common case. Since the online-decoding code needs to "know about" things like CMN and fMLLR in order to do adaptation, it's hard to make this completely generic.
Definition at line 157 of file online-feature-pipeline.h.
|
explicit |
Definition at line 113 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::global_cmvn_stats_, OnlineFeaturePipelineConfig::global_cmvn_stats_rxfilename, OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::lda_mat_, OnlineFeaturePipelineConfig::lda_rxfilename, and kaldi::ReadKaldiObject().
Referenced by OnlineFeaturePipeline::New().
|
virtual |
Definition at line 256 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::base_feature_, OnlineFeaturePipeline::cmvn_, OnlineFeaturePipeline::feature_, OnlineFeaturePipeline::fmllr_, OnlineFeaturePipeline::lda_, OnlineFeaturePipeline::pitch_, OnlineFeaturePipeline::pitch_feature_, and OnlineFeaturePipeline::splice_or_delta_.
|
private |
The following constructor is used internally in the New() function; it has the same effect as initializing from just "cfg", but avoids re-reading the LDA transform from disk.
Definition at line 104 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::Init().
void AcceptWaveform | ( | BaseFloat | sampling_rate, |
const VectorBase< BaseFloat > & | waveform | ||
) |
Accept more data to process (won't actually process it, will just copy it).
sampling_rate is necessary just to assert it equals what's in the config.
Definition at line 272 of file online-feature-pipeline.cc.
References OnlineBaseFeature::AcceptWaveform(), OnlinePitchFeature::AcceptWaveform(), OnlineFeaturePipeline::base_feature_, and OnlineFeaturePipeline::pitch_.
|
private |
returns adapted feature if fmllr_ exists, else UnadaptedFeature().
If this were not private we would have const and non-const versions returning const and non-const pointers.
Definition at line 138 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::fmllr_, and OnlineFeaturePipeline::UnadaptedFeature().
Referenced by OnlineFeaturePipeline::Dim(), OnlineFeaturePipeline::GetFrame(), OnlineFeaturePipeline::IsLastFrame(), and OnlineFeaturePipeline::NumFramesReady().
|
virtual |
Member functions from OnlineFeatureInterface:
Implements OnlineFeatureInterface.
Definition at line 241 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::AdaptedFeature(), and OnlineFeatureInterface::Dim().
Referenced by SingleUtteranceGmmDecoder::EstimateFmllr(), and SingleUtteranceGmmDecoder::GetGaussianPosteriors().
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 184 of file online-feature-pipeline.h.
Referenced by SingleUtteranceGmmDecoder::AdvanceDecoding(), and SingleUtteranceGmmDecoder::EndpointDetected().
void FreezeCmvn | ( | ) |
Definition at line 237 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::cmvn_, OnlineCmvn::Freeze(), and OnlineCmvn::NumFramesReady().
Referenced by SingleUtteranceGmmDecoder::EstimateFmllr().
Definition at line 299 of file online-feature-pipeline.cc.
References OnlineProcessPitch::Dim(), OnlineProcessPitch::GetFrame(), rnnlm::i, OnlineFeaturePipeline::NumFramesReady(), OnlineFeaturePipeline::pitch_, OnlineFeaturePipeline::pitch_feature_, and Matrix< Real >::Resize().
Referenced by SingleUtteranceGmmDecoder::EstimateFmllr().
void GetCmvnState | ( | OnlineCmvnState * | cmvn_state | ) |
Definition at line 149 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::cmvn_, OnlineCmvn::GetState(), and OnlineCmvn::NumFramesReady().
Referenced by SingleUtteranceGmmDecoder::GetAdaptationState().
|
virtual |
Gets the feature vector for this frame.
Before calling this for a given frame, it is assumed that you called NumFramesReady() and it returned a number greater than "frame". Otherwise this call will likely crash with an assert failure. This function is not declared const, in case there is some kind of caching going on, but most of the time it shouldn't modify the class.
Implements OnlineFeatureInterface.
Definition at line 251 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::AdaptedFeature(), and OnlineFeatureInterface::GetFrame().
Referenced by SingleUtteranceGmmDecoder::EstimateFmllr(), and SingleUtteranceGmmDecoder::GetGaussianPosteriors().
|
inline |
Definition at line 201 of file online-feature-pipeline.h.
Referenced by SingleUtteranceGmmDecoder::HaveTransform().
|
private |
Init() is to be called from the constructor; it assumes the pointer members are all uninitialized but config_ and lda_mat_ are initialized.
Definition at line 159 of file online-feature-pipeline.cc.
References OnlineFeaturePipelineConfig::add_deltas, OnlineFeaturePipelineConfig::add_pitch, OnlineFeaturePipeline::base_feature_, OnlineFeaturePipeline::cmvn_, OnlineFeaturePipelineConfig::cmvn_opts, MatrixBase< Real >::ColRange(), OnlineFeaturePipeline::config_, OnlineFeaturePipelineConfig::delta_opts, OnlineFeatureInterface::Dim(), OnlineFeaturePipelineConfig::fbank_opts, OnlineFeaturePipeline::feature_, OnlineFeaturePipelineConfig::feature_type, OnlineFeaturePipeline::fmllr_, OnlineFeaturePipeline::global_cmvn_stats_, KALDI_ASSERT, KALDI_ERR, kaldi::kCopyData, OnlineFeaturePipeline::lda_, OnlineFeaturePipeline::lda_mat_, OnlineFeaturePipelineConfig::mfcc_opts, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), OnlineFeaturePipeline::pitch_, OnlineFeaturePipeline::pitch_feature_, OnlineFeaturePipelineConfig::pitch_opts, OnlineFeaturePipelineConfig::pitch_process_opts, OnlineFeaturePipelineConfig::plp_opts, Matrix< Real >::Resize(), OnlineFeaturePipelineConfig::splice_feats, OnlineFeaturePipelineConfig::splice_opts, and OnlineFeaturePipeline::splice_or_delta_.
Referenced by OnlineFeaturePipeline::OnlineFeaturePipeline().
void InputFinished | ( | ) |
Definition at line 280 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::base_feature_, OnlineBaseFeature::InputFinished(), OnlinePitchFeature::InputFinished(), and OnlineFeaturePipeline::pitch_.
Returns true if this is the last frame.
Frame indices are zero-based, so the first frame is zero. IsLastFrame(-1) will return false, unless the file is empty (which is a case that I'm not sure all the code will handle, so be careful). This function may return false for some frame if we haven't yet decided to terminate decoding, but later true if we decide to terminate decoding. This function exists mainly to correctly handle end effects in feature extraction, and is not a mechanism to determine how many frames are in the decodable object (as it used to be, and for backward compatibility, still is, in the Decodable interface).
Implements OnlineFeatureInterface.
Definition at line 244 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::AdaptedFeature(), and OnlineFeatureInterface::IsLastFrame().
OnlineFeaturePipeline * New | ( | ) | const |
returns a newly initialized copy of *this– this does not duplicate all the internal state or the speaker-adaptation state, but gives you a freshly initialized version of this object, as if you had initialized it using the constructor that takes the config file.
After calling this you may want to call SetCmvnState() and SetTransform().
Definition at line 124 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::config_, OnlineFeaturePipeline::global_cmvn_stats_, OnlineFeaturePipeline::lda_mat_, and OnlineFeaturePipeline::OnlineFeaturePipeline().
|
virtual |
returns the feature dimension.
Returns the total number of frames, since the start of the utterance, that are now available. In an online-decoding context, this will likely increase with time as more data becomes available.
Implements OnlineFeatureInterface.
Definition at line 247 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::AdaptedFeature(), and OnlineFeatureInterface::NumFramesReady().
Referenced by OnlineFeaturePipeline::GetAsMatrix().
void SetCmvnState | ( | const OnlineCmvnState & | cmvn_state | ) |
Set the CMVN state to a particular value (will generally be called after Copy().
Definition at line 145 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::cmvn_, and OnlineCmvn::SetState().
void SetTransform | ( | const MatrixBase< BaseFloat > & | transform | ) |
Definition at line 223 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::fmllr_, MatrixBase< Real >::NumRows(), and OnlineFeaturePipeline::UnadaptedFeature().
Referenced by SingleUtteranceGmmDecoder::EstimateFmllr(), and SingleUtteranceGmmDecoder::SingleUtteranceGmmDecoder().
|
private |
returns lda_ if it exists, else splice_or_delta_, else cmvn_.
If this were not private we would have const and non-const versions returning const and non-const pointers.
Definition at line 129 of file online-feature-pipeline.cc.
References OnlineFeaturePipeline::feature_, KALDI_ASSERT, OnlineFeaturePipeline::lda_, and OnlineFeaturePipeline::splice_or_delta_.
Referenced by OnlineFeaturePipeline::AdaptedFeature(), and OnlineFeaturePipeline::SetTransform().
|
private |
Definition at line 229 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::AcceptWaveform(), OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::InputFinished(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
|
private |
Definition at line 234 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::FreezeCmvn(), OnlineFeaturePipeline::GetCmvnState(), OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::SetCmvnState(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
|
private |
Definition at line 225 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::Init(), and OnlineFeaturePipeline::New().
|
private |
Definition at line 232 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::UnadaptedFeature(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
|
private |
Definition at line 245 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::AdaptedFeature(), OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::SetTransform(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
Definition at line 227 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::New(), and OnlineFeaturePipeline::OnlineFeaturePipeline().
|
private |
Definition at line 238 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::UnadaptedFeature(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
Definition at line 226 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::New(), and OnlineFeaturePipeline::OnlineFeaturePipeline().
|
private |
Definition at line 230 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::AcceptWaveform(), OnlineFeaturePipeline::GetAsMatrix(), OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::InputFinished(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
|
private |
Definition at line 231 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::GetAsMatrix(), OnlineFeaturePipeline::Init(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().
|
private |
Definition at line 235 of file online-feature-pipeline.h.
Referenced by OnlineFeaturePipeline::Init(), OnlineFeaturePipeline::UnadaptedFeature(), and OnlineFeaturePipeline::~OnlineFeaturePipeline().