This feature type can be used to cache its input, to avoid repetition of computation in a multi-pass decoding context. 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... | |
virtual | ~OnlineCacheFeature () |
void | ClearCache () |
OnlineCacheFeature (OnlineFeatureInterface *src) | |
Public Member Functions inherited from OnlineFeatureInterface | |
virtual | ~OnlineFeatureInterface () |
Virtual destructor. More... | |
Private Attributes | |
OnlineFeatureInterface * | src_ |
std::vector< Vector< BaseFloat > *> | cache_ |
This feature type can be used to cache its input, to avoid repetition of computation in a multi-pass decoding context.
Definition at line 564 of file online-feature.h.
|
inlinevirtual |
Definition at line 582 of file online-feature.h.
|
inlineexplicit |
Definition at line 589 of file online-feature.h.
void ClearCache | ( | ) |
Definition at line 662 of file online-feature.cc.
References rnnlm::i.
Referenced by kaldi::GetOutput().
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 566 of file online-feature.h.
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 571 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 604 of file online-feature.cc.
References VectorBase< Real >::CopyFromVec(), OnlineDeltaFeature::Dim(), OnlineFeatureInterface::GetFrame(), KALDI_ASSERT, and OnlineDeltaFeature::src_.
Referenced by kaldi::GetOutput().
|
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 619 of file online-feature.cc.
References OnlineDeltaFeature::Dim(), OnlineFeatureInterface::GetFrames(), rnnlm::i, kaldi::kUndefined, MatrixBase< Real >::Row(), and OnlineDeltaFeature::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 568 of file online-feature.h.
Referenced by kaldi::GetOutput().
|
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 575 of file online-feature.h.
Definition at line 593 of file online-feature.h.
|
private |
Definition at line 592 of file online-feature.h.