OnlineMatrixFeature Class Reference

This class takes a Matrix<BaseFloat> and wraps it as an OnlineFeatureInterface: this can be useful where some earlier stage of feature processing has been done offline but you want to use part of the online pipeline. More...

#include <online-feature.h>

Inheritance diagram for OnlineMatrixFeature:
Collaboration diagram for OnlineMatrixFeature:

Public Member Functions

 OnlineMatrixFeature (const MatrixBase< BaseFloat > &mat)
 Caution: this class maintains the const reference from the constructor, so don't let it go out of scope while this object exists. More...
 
virtual int32 Dim () const
 
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 bool IsLastFrame (int32 frame) const
 Returns true if this is the last frame. 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 Attributes

const MatrixBase< BaseFloat > & mat_
 

Detailed Description

This class takes a Matrix<BaseFloat> and wraps it as an OnlineFeatureInterface: this can be useful where some earlier stage of feature processing has been done offline but you want to use part of the online pipeline.

Definition at line 167 of file online-feature.h.

Constructor & Destructor Documentation

◆ OnlineMatrixFeature()

OnlineMatrixFeature ( const MatrixBase< BaseFloat > &  mat)
inlineexplicit

Caution: this class maintains the const reference from the constructor, so don't let it go out of scope while this object exists.

Definition at line 171 of file online-feature.h.

171 : mat_(mat) { }
const MatrixBase< BaseFloat > & mat_

Member Function Documentation

◆ Dim()

virtual int32 Dim ( ) const
inlinevirtual

Implements OnlineFeatureInterface.

Definition at line 173 of file online-feature.h.

173 { return mat_.NumCols(); }
const MatrixBase< BaseFloat > & mat_

◆ FrameShiftInSeconds()

virtual BaseFloat FrameShiftInSeconds ( ) const
inlinevirtual

Implements OnlineFeatureInterface.

Definition at line 175 of file online-feature.h.

175  {
176  return 0.01f;
177  }

◆ GetFrame()

virtual void GetFrame ( int32  frame,
VectorBase< BaseFloat > *  feat 
)
inlinevirtual

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 181 of file online-feature.h.

References VectorBase< Real >::CopyFromVec().

181  {
182  feat->CopyFromVec(mat_.Row(frame));
183  }
const MatrixBase< BaseFloat > & mat_

◆ IsLastFrame()

virtual bool IsLastFrame ( int32  frame) const
inlinevirtual

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 185 of file online-feature.h.

185  {
186  return (frame + 1 == mat_.NumRows());
187  }
const MatrixBase< BaseFloat > & mat_

◆ NumFramesReady()

virtual int32 NumFramesReady ( ) const
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 179 of file online-feature.h.

179 { return mat_.NumRows(); }
const MatrixBase< BaseFloat > & mat_

Member Data Documentation

◆ mat_

const MatrixBase<BaseFloat>& mat_
private

Definition at line 191 of file online-feature.h.


The documentation for this class was generated from the following file: