This online-feature class implements any affine or linear transform. 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... | |
virtual void | GetFrames (const std::vector< int32 > &frames, MatrixBase< BaseFloat > *feats) |
This is like GetFrame() but for a collection of frames. More... | |
OnlineTransform (const MatrixBase< BaseFloat > &transform, OnlineFeatureInterface *src) | |
The transform can be a linear transform, or an affine transform where the last column is the offset. More... | |
Public Member Functions inherited from OnlineFeatureInterface | |
virtual | ~OnlineFeatureInterface () |
Virtual destructor. More... | |
Private Attributes | |
OnlineFeatureInterface * | src_ |
Matrix< BaseFloat > | linear_term_ |
Vector< BaseFloat > | offset_ |
This online-feature class implements any affine or linear transform.
Definition at line 493 of file online-feature.h.
OnlineTransform | ( | const MatrixBase< BaseFloat > & | transform, |
OnlineFeatureInterface * | src | ||
) |
The transform can be a linear transform, or an affine transform where the last column is the offset.
Definition at line 521 of file online-feature.cc.
References OnlineFeatureInterface::Dim(), KALDI_ERR, OnlineTransform::linear_term_, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), OnlineTransform::offset_, MatrixBase< Real >::Range(), and OnlineTransform::src_.
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 498 of file online-feature.h.
Referenced by OnlineDeltaFeature::GetFrame().
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 503 of file online-feature.h.
|
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 538 of file online-feature.cc.
References VectorBase< Real >::AddMatVec(), VectorBase< Real >::CopyFromVec(), OnlineFeatureInterface::GetFrame(), kaldi::kNoTrans, OnlineTransform::linear_term_, MatrixBase< Real >::NumCols(), OnlineTransform::offset_, and OnlineTransform::src_.
|
virtual |
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 from OnlineFeatureInterface.
Definition at line 545 of file online-feature.cc.
References MatrixBase< Real >::AddMatMat(), MatrixBase< Real >::CopyRowsFromVec(), OnlineFeatureInterface::GetFrames(), KALDI_ASSERT, kaldi::kNoTrans, kaldi::kTrans, kaldi::kUndefined, OnlineTransform::linear_term_, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), OnlineTransform::offset_, and OnlineTransform::src_.
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 500 of file online-feature.h.
|
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 507 of file online-feature.h.
Referenced by OnlineDeltaFeature::GetFrame().
Definition at line 526 of file online-feature.h.
Referenced by OnlineTransform::GetFrame(), OnlineTransform::GetFrames(), and OnlineTransform::OnlineTransform().
Definition at line 527 of file online-feature.h.
Referenced by OnlineTransform::GetFrame(), OnlineTransform::GetFrames(), and OnlineTransform::OnlineTransform().
|
private |
Definition at line 525 of file online-feature.h.
Referenced by OnlineDeltaFeature::Dim(), OnlineTransform::GetFrame(), OnlineDeltaFeature::GetFrame(), OnlineTransform::GetFrames(), OnlineDeltaFeature::NumFramesReady(), and OnlineTransform::OnlineTransform().