OnlineAppendFeature Class Reference

This online-feature class implements combination of two feature streams (such as pitch, plp) into one stream. More...

#include <online-feature.h>

Inheritance diagram for OnlineAppendFeature:
Collaboration diagram for OnlineAppendFeature:

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 ~OnlineAppendFeature ()
 
 OnlineAppendFeature (OnlineFeatureInterface *src1, OnlineFeatureInterface *src2)
 
- 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

OnlineFeatureInterfacesrc1_
 
OnlineFeatureInterfacesrc2_
 

Detailed Description

This online-feature class implements combination of two feature streams (such as pitch, plp) into one stream.

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

Constructor & Destructor Documentation

◆ ~OnlineAppendFeature()

virtual ~OnlineAppendFeature ( )
inlinevirtual

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

619 { }

◆ OnlineAppendFeature()

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

622  : src1_(src1), src2_(src2) { }
OnlineFeatureInterface * src2_
OnlineFeatureInterface * src1_

Member Function Documentation

◆ Dim()

virtual int32 Dim ( ) const
inlinevirtual

Implements OnlineFeatureInterface.

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

603 { return src1_->Dim() + src2_->Dim(); }
OnlineFeatureInterface * src2_
OnlineFeatureInterface * src1_
virtual int32 Dim() const =0

◆ FrameShiftInSeconds()

virtual BaseFloat FrameShiftInSeconds ( ) const
inlinevirtual

Implements OnlineFeatureInterface.

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

609  {
610  return src1_->FrameShiftInSeconds();
611  }
virtual BaseFloat FrameShiftInSeconds() const =0
OnlineFeatureInterface * src1_

◆ GetFrame()

void GetFrame ( int32  frame,
VectorBase< BaseFloat > *  feat 
)
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 669 of file online-feature.cc.

References VectorBase< Real >::Dim(), OnlineDeltaFeature::Dim(), and KALDI_ASSERT.

669  {
670  KALDI_ASSERT(feat->Dim() == Dim());
671 
672  SubVector<BaseFloat> feat1(*feat, 0, src1_->Dim());
673  SubVector<BaseFloat> feat2(*feat, src1_->Dim(), src2_->Dim());
674  src1_->GetFrame(frame, &feat1);
675  src2_->GetFrame(frame, &feat2);
676 };
virtual void GetFrame(int32 frame, VectorBase< BaseFloat > *feat)=0
Gets the feature vector for this frame.
virtual int32 Dim() const
OnlineFeatureInterface * src2_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
OnlineFeatureInterface * src1_
virtual int32 Dim() const =0

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

605  {
606  return (src1_->IsLastFrame(frame) || src2_->IsLastFrame(frame));
607  }
virtual bool IsLastFrame(int32 frame) const =0
Returns true if this is the last frame.
OnlineFeatureInterface * src2_
OnlineFeatureInterface * src1_

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

613  {
614  return std::min(src1_->NumFramesReady(), src2_->NumFramesReady());
615  }
OnlineFeatureInterface * src2_
OnlineFeatureInterface * src1_
virtual int32 NumFramesReady() const =0
returns the feature dimension.

Member Data Documentation

◆ src1_

OnlineFeatureInterface* src1_
private

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

◆ src2_

OnlineFeatureInterface* src2_
private

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


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