This is a templated class for online feature extraction; it's templated on a class like MfccComputer or PlpComputer that does the basic feature extraction. More...
#include <online-feature.h>
Public Member Functions | |
virtual int32 | Dim () const |
virtual bool | IsLastFrame (int32 frame) const |
Returns true if this is the last frame. More... | |
virtual BaseFloat | FrameShiftInSeconds () const |
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... | |
OnlineGenericBaseFeature (const typename C::Options &opts) | |
virtual void | AcceptWaveform (BaseFloat sampling_rate, const VectorBase< BaseFloat > &waveform) |
This would be called from the application, when you get more wave data. More... | |
virtual void | InputFinished () |
InputFinished() tells the class you won't be providing any more waveform. More... | |
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 | |
void | ComputeFeatures () |
void | MaybeCreateResampler (BaseFloat sampling_rate) |
Private Attributes | |
C | computer_ |
std::unique_ptr< LinearResample > | resampler_ |
FeatureWindowFunction | window_function_ |
RecyclingVector | features_ |
bool | input_finished_ |
BaseFloat | sampling_frequency_ |
int64 | waveform_offset_ |
Vector< BaseFloat > | waveform_remainder_ |
This is a templated class for online feature extraction; it's templated on a class like MfccComputer or PlpComputer that does the basic feature extraction.
Definition at line 78 of file online-feature.h.
|
explicit |
Definition at line 70 of file online-feature.cc.
References KALDI_ASSERT.
|
virtual |
This would be called from the application, when you get more wave data.
Note: the sampling_rate is typically only provided so the code can assert that it matches the sampling rate expected in the options.
Implements OnlineBaseFeature.
Definition at line 131 of file online-feature.cc.
References OnlineGenericBaseFeature< C >::ComputeFeatures(), VectorBase< Real >::Dim(), OnlineGenericBaseFeature< C >::input_finished_, KALDI_ERR, OnlineGenericBaseFeature< C >::MaybeCreateResampler(), VectorBase< Real >::Range(), OnlineGenericBaseFeature< C >::resampler_, Vector< Real >::Resize(), and OnlineGenericBaseFeature< C >::waveform_remainder_.
Referenced by kaldi::TestOnlineAppendFeature(), kaldi::TestOnlineMfcc(), kaldi::TestOnlinePlp(), and kaldi::TestOnlineTransform().
|
private |
Definition at line 162 of file online-feature.cc.
References OnlineGenericBaseFeature< C >::computer_, VectorBase< Real >::CopyFromVec(), kaldi::ExtractWindow(), OnlineGenericBaseFeature< C >::features_, kaldi::FirstSampleOfFrame(), OnlineGenericBaseFeature< C >::input_finished_, KALDI_ASSERT, kaldi::kUndefined, kaldi::NumFrames(), RecyclingVector::PushBack(), RecyclingVector::Size(), OnlineGenericBaseFeature< C >::waveform_offset_, OnlineGenericBaseFeature< C >::waveform_remainder_, and OnlineGenericBaseFeature< C >::window_function_.
Referenced by OnlineGenericBaseFeature< C >::AcceptWaveform(), and OnlineGenericBaseFeature< C >::InputFinished().
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 83 of file online-feature.h.
Referenced by kaldi::TestOnlineTransform().
|
inlinevirtual |
|
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 64 of file online-feature.cc.
References VectorBase< Real >::CopyFromVec().
|
virtual |
InputFinished() tells the class you won't be providing any more waveform.
This will help flush out the last few frames of delta or LDA features (it will typically affect the return value of IsLastFrame.
Implements OnlineBaseFeature.
Definition at line 107 of file online-feature.cc.
References OnlineGenericBaseFeature< C >::ComputeFeatures(), VectorBase< Real >::Dim(), OnlineGenericBaseFeature< C >::input_finished_, VectorBase< Real >::Range(), OnlineGenericBaseFeature< C >::resampler_, Vector< Real >::Resize(), and OnlineGenericBaseFeature< C >::waveform_remainder_.
Referenced by kaldi::TestOnlineAppendFeature(), kaldi::TestOnlineMfcc(), kaldi::TestOnlinePlp(), and kaldi::TestOnlineTransform().
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 87 of file online-feature.h.
|
private |
Definition at line 84 of file online-feature.cc.
References OnlineGenericBaseFeature< C >::computer_, KALDI_ASSERT, KALDI_ERR, and OnlineGenericBaseFeature< C >::resampler_.
Referenced by OnlineGenericBaseFeature< C >::AcceptWaveform().
|
inlinevirtual |
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 94 of file online-feature.h.
|
private |
Definition at line 129 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::ComputeFeatures(), and OnlineGenericBaseFeature< C >::MaybeCreateResampler().
|
private |
Definition at line 139 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::ComputeFeatures().
|
private |
Definition at line 142 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::AcceptWaveform(), OnlineGenericBaseFeature< C >::ComputeFeatures(), and OnlineGenericBaseFeature< C >::InputFinished().
|
private |
Definition at line 133 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::AcceptWaveform(), OnlineGenericBaseFeature< C >::InputFinished(), and OnlineGenericBaseFeature< C >::MaybeCreateResampler().
|
private |
Definition at line 146 of file online-feature.h.
|
private |
Definition at line 150 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::ComputeFeatures().
Definition at line 155 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::AcceptWaveform(), OnlineGenericBaseFeature< C >::ComputeFeatures(), and OnlineGenericBaseFeature< C >::InputFinished().
|
private |
Definition at line 135 of file online-feature.h.
Referenced by OnlineGenericBaseFeature< C >::ComputeFeatures().