This online-feature class implements post processing of pitch features. More...
#include <pitch-functions.h>
Classes | |
struct | NormalizationStats |
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 | ~OnlineProcessPitch () |
OnlineProcessPitch (const ProcessPitchOptions &opts, OnlineFeatureInterface *src) | |
Note on the implementation of OnlineProcessPitch: the OnlineFeatureInterface allows random access to features (i.e. 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 Types | |
enum | { kRawFeatureDim = 2 } |
Private Member Functions | |
BaseFloat | GetPovFeature (int32 frame) const |
Computes and returns the POV feature for this frame. More... | |
BaseFloat | GetDeltaPitchFeature (int32 frame) |
Computes and returns the delta-log-pitch feature for this frame. More... | |
BaseFloat | GetRawLogPitchFeature (int32 frame) const |
Computes and returns the raw log-pitch feature for this frame. More... | |
BaseFloat | GetNormalizedLogPitchFeature (int32 frame) |
Computes and returns the mean-subtracted log-pitch feature for this frame. More... | |
void | GetNormalizationWindow (int32 frame, int32 src_frames_ready, int32 *window_begin, int32 *window_end) const |
Computes the normalization window sizes. More... | |
void | UpdateNormalizationStats (int32 frame) |
Makes sure the entry in normalization_stats_ for this frame is up to date; called from GetNormalizedLogPitchFeature. More... | |
Private Attributes | |
ProcessPitchOptions | opts_ |
OnlineFeatureInterface * | src_ |
int32 | dim_ |
std::vector< BaseFloat > | delta_feature_noise_ |
std::vector< NormalizationStats > | normalization_stats_ |
This online-feature class implements post processing of pitch features.
Inputs are original 2 dims (nccf, pitch). It can produce various kinds of outputs, using the default options it will be (pov-feature, normalized-log-pitch, delta-log-pitch).
Definition at line 332 of file pitch-functions.h.
|
private |
|
inlinevirtual |
Definition at line 352 of file pitch-functions.h.
OnlineProcessPitch | ( | const ProcessPitchOptions & | opts, |
OnlineFeatureInterface * | src | ||
) |
Note on the implementation of OnlineProcessPitch: the OnlineFeatureInterface allows random access to features (i.e.
not necessarily sequential order), so we need to support that. But we don't need to support it very efficiently, and our implementation is most efficient if frames are accessed in sequential order.
Also note: we have to be a bit careful in this implementation because the input features may change. That is: if we call src_->GetFrame(t, &vec) from GetFrame(), we can't guarantee that a later call to src_->GetFrame(t, &vec) from another GetFrame() will return the same value. In fact, while designing this class we used some knowledge of how the OnlinePitchFeature class works to minimize the amount of re-querying we had to do.
Definition at line 1398 of file pitch-functions.cc.
References OnlineFeatureInterface::Dim(), OnlineProcessPitch::dim_, KALDI_ASSERT, and OnlineProcessPitch::kRawFeatureDim.
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 334 of file pitch-functions.h.
Referenced by kaldi::ComputeAndProcessKaldiPitch(), OnlineFeaturePipeline::GetAsMatrix(), kaldi::ProcessPitch(), kaldi::UnitTestDelay(), and kaldi::UnitTestPieces().
|
inlinevirtual |
Implements OnlineFeatureInterface.
Definition at line 344 of file pitch-functions.h.
Computes and returns the delta-log-pitch feature for this frame.
Called from GetFrame().
Definition at line 1439 of file pitch-functions.cc.
References kaldi::ComputeDeltas(), OnlineProcessPitch::delta_feature_noise_, ProcessPitchOptions::delta_pitch_noise_stddev, ProcessPitchOptions::delta_pitch_scale, ProcessPitchOptions::delta_window, OnlineProcessPitch::GetRawLogPitchFeature(), OnlineFeatureInterface::NumFramesReady(), OnlineProcessPitch::opts_, DeltaFeaturesOptions::order, kaldi::RandGauss(), OnlineProcessPitch::src_, and DeltaFeaturesOptions::window.
Referenced by OnlineProcessPitch::GetFrame().
|
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 1414 of file pitch-functions.cc.
References ProcessPitchOptions::add_delta_pitch, ProcessPitchOptions::add_normalized_log_pitch, ProcessPitchOptions::add_pov_feature, ProcessPitchOptions::add_raw_log_pitch, ProcessPitchOptions::delay, VectorBase< Real >::Dim(), OnlineProcessPitch::dim_, OnlineProcessPitch::GetDeltaPitchFeature(), OnlineProcessPitch::GetNormalizedLogPitchFeature(), OnlineProcessPitch::GetPovFeature(), OnlineProcessPitch::GetRawLogPitchFeature(), KALDI_ASSERT, OnlineProcessPitch::NumFramesReady(), and OnlineProcessPitch::opts_.
Referenced by kaldi::ComputeAndProcessKaldiPitch(), OnlineFeaturePipeline::GetAsMatrix(), kaldi::ProcessPitch(), kaldi::UnitTestDelay(), and kaldi::UnitTestPieces().
|
inlineprivate |
Computes the normalization window sizes.
Definition at line 1487 of file pitch-functions.cc.
References ProcessPitchOptions::normalization_left_context, ProcessPitchOptions::normalization_right_context, and OnlineProcessPitch::opts_.
Referenced by OnlineProcessPitch::UpdateNormalizationStats().
Computes and returns the mean-subtracted log-pitch feature for this frame.
Called from GetFrame().
Definition at line 1476 of file pitch-functions.cc.
References OnlineProcessPitch::GetRawLogPitchFeature(), OnlineProcessPitch::normalization_stats_, OnlineProcessPitch::opts_, ProcessPitchOptions::pitch_scale, and OnlineProcessPitch::UpdateNormalizationStats().
Referenced by OnlineProcessPitch::GetFrame().
Computes and returns the POV feature for this frame.
Called from GetFrame().
Definition at line 1431 of file pitch-functions.cc.
References OnlineFeatureInterface::GetFrame(), OnlineProcessPitch::kRawFeatureDim, kaldi::NccfToPovFeature(), OnlineProcessPitch::opts_, ProcessPitchOptions::pov_offset, ProcessPitchOptions::pov_scale, and OnlineProcessPitch::src_.
Referenced by OnlineProcessPitch::GetFrame().
Computes and returns the raw log-pitch feature for this frame.
Called from GetFrame().
Definition at line 1468 of file pitch-functions.cc.
References OnlineFeatureInterface::GetFrame(), KALDI_ASSERT, OnlineProcessPitch::kRawFeatureDim, kaldi::Log(), and OnlineProcessPitch::src_.
Referenced by OnlineProcessPitch::GetDeltaPitchFeature(), OnlineProcessPitch::GetFrame(), and OnlineProcessPitch::GetNormalizedLogPitchFeature().
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 336 of file pitch-functions.h.
|
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.
Implements OnlineFeatureInterface.
Definition at line 1569 of file pitch-functions.cc.
References ProcessPitchOptions::delay, OnlineFeatureInterface::IsLastFrame(), ProcessPitchOptions::normalization_right_context, OnlineFeatureInterface::NumFramesReady(), OnlineProcessPitch::opts_, and OnlineProcessPitch::src_.
Referenced by kaldi::ComputeAndProcessKaldiPitch(), OnlineProcessPitch::GetFrame(), kaldi::ProcessPitch(), and kaldi::UnitTestDelay().
|
inlineprivate |
Makes sure the entry in normalization_stats_ for this frame is up to date; called from GetNormalizedLogPitchFeature.
Definition at line 1502 of file pitch-functions.cc.
References OnlineProcessPitch::NormalizationStats::cur_num_frames, OnlineFeatureInterface::GetFrame(), OnlineProcessPitch::GetNormalizationWindow(), OnlineProcessPitch::NormalizationStats::input_finished, OnlineFeatureInterface::IsLastFrame(), KALDI_ASSERT, OnlineProcessPitch::kRawFeatureDim, kaldi::Log(), kaldi::NccfToPov(), OnlineProcessPitch::normalization_stats_, OnlineFeatureInterface::NumFramesReady(), OnlineProcessPitch::src_, OnlineProcessPitch::NormalizationStats::sum_log_pitch_pov, and OnlineProcessPitch::NormalizationStats::sum_pov.
Referenced by OnlineProcessPitch::GetNormalizedLogPitchFeature().
|
private |
Definition at line 379 of file pitch-functions.h.
Referenced by OnlineProcessPitch::GetDeltaPitchFeature().
|
private |
Definition at line 365 of file pitch-functions.h.
Referenced by OnlineProcessPitch::GetFrame(), and OnlineProcessPitch::OnlineProcessPitch().
|
private |
Definition at line 381 of file pitch-functions.h.
Referenced by OnlineProcessPitch::GetNormalizedLogPitchFeature(), and OnlineProcessPitch::UpdateNormalizationStats().
|
private |
Definition at line 363 of file pitch-functions.h.
Referenced by OnlineProcessPitch::GetDeltaPitchFeature(), OnlineProcessPitch::GetFrame(), OnlineProcessPitch::GetNormalizationWindow(), OnlineProcessPitch::GetNormalizedLogPitchFeature(), OnlineProcessPitch::GetPovFeature(), and OnlineProcessPitch::NumFramesReady().
|
private |
Definition at line 364 of file pitch-functions.h.
Referenced by OnlineProcessPitch::GetDeltaPitchFeature(), OnlineProcessPitch::GetPovFeature(), OnlineProcessPitch::GetRawLogPitchFeature(), OnlineProcessPitch::NumFramesReady(), and OnlineProcessPitch::UpdateNormalizationStats().