OnlineFeatureInterface is an interface for online feature processing (it is also usable in the offline setting, but currently we're not using it for that). More...
#include <online-feature-itf.h>
Public Member Functions | |
virtual int32 | Dim () const =0 |
virtual int32 | NumFramesReady () const =0 |
returns the feature dimension. More... | |
virtual bool | IsLastFrame (int32 frame) const =0 |
Returns true if this is the last frame. More... | |
virtual void | GetFrame (int32 frame, VectorBase< BaseFloat > *feat)=0 |
Gets the feature vector for this frame. More... | |
virtual void | GetFrames (const std::vector< int32 > &frames, MatrixBase< BaseFloat > *feats) |
This is like GetFrame() but for a collection of frames. More... | |
virtual BaseFloat | FrameShiftInSeconds () const =0 |
virtual | ~OnlineFeatureInterface () |
Virtual destructor. More... | |
OnlineFeatureInterface is an interface for online feature processing (it is also usable in the offline setting, but currently we're not using it for that).
This is for use in the online2/ directory, and it supersedes the interface in ../online/online-feat-input.h. We have a slightly different model that puts more control in the hands of the calling thread, and won't involve waiting on semaphores in the decoding thread.
This interface only specifies how the object *outputs* the features. How it obtains the features, e.g. from a previous object or objects of type OnlineFeatureInterface, is not specified in the interface and you will likely define new constructors or methods in the derived type to do that.
You should appreciate that this interface is designed to allow random access to features, as long as they are ready. That is, the user can call GetFrame for any frame less than NumFramesReady(), and when implementing a child class you must not make assumptions about the order in which the user makes these calls.
Definition at line 49 of file online-feature-itf.h.
|
inlinevirtual |
Virtual destructor.
Note: constructors that take another member of type OnlineFeatureInterface are not expected to take ownership of that pointer; the caller needs to keep track of that manually.
Definition at line 99 of file online-feature-itf.h.
|
pure virtual |
Implemented in OnlineAppendFeature, OnlineCacheFeature, OnlineDeltaFeature, OnlineTransform, OnlineSpliceFrames, OnlineProcessPitch, OnlineCmvn, OnlinePitchFeature, OnlineIvectorFeature, OnlineNnet2FeaturePipeline, OnlineMatrixFeature, OnlineFeaturePipeline, and OnlineGenericBaseFeature< C >.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetLoopedOnlineBase::DecodableNnetLoopedOnlineBase(), OnlineFeaturePipeline::Dim(), OnlineDeltaFeature::Dim(), OnlineSpliceFrames::GetFrame(), OnlineDeltaFeature::GetFrame(), kaldi::GetOutput(), OnlineFeaturePipeline::Init(), OnlineNnet2FeaturePipeline::OnlineNnet2FeaturePipeline(), OnlineProcessPitch::OnlineProcessPitch(), and OnlineTransform::OnlineTransform().
|
pure virtual |
Implemented in OnlineAppendFeature, OnlineCacheFeature, OnlineDeltaFeature, OnlineTransform, OnlineSpliceFrames, OnlineProcessPitch, OnlineCmvn, OnlinePitchFeature, OnlineIvectorFeature, OnlineNnet2FeaturePipeline, OnlineFeaturePipeline, OnlineMatrixFeature, and OnlineGenericBaseFeature< C >.
Referenced by SingleUtteranceNnet2Decoder::EndpointDetected(), and OnlineFeatureInterface::GetFrames().
|
pure 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.
Implemented in OnlineAppendFeature, OnlineCacheFeature, OnlineDeltaFeature, OnlineTransform, OnlineSpliceFrames, OnlineProcessPitch, OnlineCmvn, OnlinePitchFeature, OnlineIvectorFeature, OnlineNnet2FeaturePipeline, OnlineMatrixFeature, OnlineFeaturePipeline, and OnlineGenericBaseFeature< C >.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableDiagGmmScaledOnline::CacheFrame(), DecodableNnet2Online::ComputeForFrame(), OnlineCmvn::ComputeStatsForFrame(), OnlineFeaturePipeline::GetFrame(), OnlineNnet2FeaturePipeline::GetFrame(), OnlineCmvn::GetFrame(), OnlineSpliceFrames::GetFrame(), OnlineTransform::GetFrame(), OnlineDeltaFeature::GetFrame(), OnlineCacheFeature::GetFrame(), OnlineFeatureInterface::GetFrames(), OnlineProcessPitch::GetPovFeature(), OnlineProcessPitch::GetRawLogPitchFeature(), OnlineCmvn::GetState(), and OnlineProcessPitch::UpdateNormalizationStats().
|
inlinevirtual |
This is like GetFrame() but for a collection of frames.
There is a default implementation that just gets the frames one by one, but it may be overridden for efficiency by child classes (since sometimes it's more efficient to do things in a batch).
Reimplemented in OnlineCacheFeature, and OnlineTransform.
Definition at line 82 of file online-feature-itf.h.
References OnlineFeatureInterface::FrameShiftInSeconds(), OnlineFeatureInterface::GetFrame(), rnnlm::i, KALDI_ASSERT, and MatrixBase< Real >::NumRows().
Referenced by OnlineTransform::GetFrames(), and OnlineCacheFeature::GetFrames().
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).
Implemented in OnlineAppendFeature, OnlineCacheFeature, OnlineDeltaFeature, OnlineTransform, OnlineSpliceFrames, OnlineProcessPitch, OnlineCmvn, OnlinePitchFeature, OnlineIvectorFeature, OnlineNnet2FeaturePipeline, OnlineMatrixFeature, OnlineFeaturePipeline, and OnlineGenericBaseFeature< C >.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnet2Online::ComputeForFrame(), DecodableDiagGmmScaledOnline::IsLastFrame(), DecodableNnetLoopedOnlineBase::IsLastFrame(), DecodableNnet2Online::IsLastFrame(), OnlineFeaturePipeline::IsLastFrame(), OnlineNnet2FeaturePipeline::IsLastFrame(), DecodableNnetLoopedOnlineBase::NumFramesReady(), DecodableNnet2Online::NumFramesReady(), OnlineProcessPitch::NumFramesReady(), OnlineSpliceFrames::NumFramesReady(), OnlineDeltaFeature::NumFramesReady(), and OnlineProcessPitch::UpdateNormalizationStats().
|
pure 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.
Implemented in OnlineAppendFeature, OnlineCacheFeature, OnlineDeltaFeature, OnlineTransform, OnlineSpliceFrames, OnlineProcessPitch, OnlineCmvn, OnlinePitchFeature, OnlineIvectorFeature, OnlineNnet2FeaturePipeline, OnlineMatrixFeature, OnlineFeaturePipeline, and OnlineGenericBaseFeature< C >.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnet2Online::ComputeForFrame(), OnlineProcessPitch::GetDeltaPitchFeature(), OnlineSpliceFrames::GetFrame(), OnlineDeltaFeature::GetFrame(), kaldi::GetOutput(), DecodableNnetLoopedOnlineBase::IsLastFrame(), DecodableDiagGmmScaledOnline::NumFramesReady(), DecodableNnetLoopedOnlineBase::NumFramesReady(), DecodableNnet2Online::NumFramesReady(), OnlineFeaturePipeline::NumFramesReady(), OnlineNnet2FeaturePipeline::NumFramesReady(), OnlineProcessPitch::NumFramesReady(), OnlineSpliceFrames::NumFramesReady(), OnlineDeltaFeature::NumFramesReady(), and OnlineProcessPitch::UpdateNormalizationStats().