kaldi-native-fbank C++ API
Kaldi-compatible feature extraction C++ API
Loading...
Searching...
No Matches
knf::OnlinePitch Class Reference

Streaming pitch extraction with post-processing (kaldi's OnlinePitchFeature + OnlineProcessPitch). More...

#include <feature-pitch.h>

Public Member Functions

 OnlinePitch (const PitchExtractionOptions &opts, const ProcessPitchOptions &popts={})
 Construct with the given extraction and post-processing options.
 ~OnlinePitch ()
int32_t Dim () const
float FrameShiftInSeconds () const
int32_t NumFramesReady () const
bool IsLastFrame (int32_t frame) const
std::vector< float > GetFrame (int32_t frame) const
 Return the frame-th feature vector.
void AcceptWaveform (float sampling_rate, const float *waveform, int32_t n)
 Add waveform samples to the extractor.
void InputFinished ()
 Tell the extractor no more waveform will be added; this flushes out the last frames and fixes the features of all frames.

Detailed Description

Streaming pitch extraction with post-processing (kaldi's OnlinePitchFeature + OnlineProcessPitch).

This is the streaming interface of kaldi's compute-and-process-kaldi-pitch-feats: it consumes waveform chunks and produces the processed pitch features (by default 3-dimensional: POV, normalized-log-pitch, delta-pitch).

Usage mirrors OnlineMfcc: feed the waveform with AcceptWaveform(), call InputFinished() when no more data is coming, then read frames with GetFrame(). Frames may become available before InputFinished() (with latency: see normalization_right_context and max_frames_latency), and InputFinished() flushes the remainder.

Features for a given frame may be revised as more data arrives (the Viterbi traceback and the normalization window settle over time), except for the delta-pitch noise which is drawn once per frame. After InputFinished(), the features are final and stable.

Used by:
Batch extraction via ComputeAndProcessKaldiPitch; MFA-style feature pipelines that append pitch to MFCC (paste-feats).
See also
PitchExtractionOptions, ProcessPitchOptions, ComputeAndProcessKaldiPitch, OnlineMfcc

Constructor & Destructor Documentation

◆ OnlinePitch()

knf::OnlinePitch::OnlinePitch ( const PitchExtractionOptions & opts,
const ProcessPitchOptions & popts = {} )
explicit

Construct with the given extraction and post-processing options.

Parameters
[in]optsRaw pitch extraction options.
[in]poptsPost-processing options; at least one of the add_* flags must be true.

◆ ~OnlinePitch()

knf::OnlinePitch::~OnlinePitch ( )

Member Function Documentation

◆ AcceptWaveform()

void knf::OnlinePitch::AcceptWaveform ( float sampling_rate,
const float * waveform,
int32_t n )

Add waveform samples to the extractor.

Parameters
[in]sampling_rateSample rate of the waveform in Hz; must match opts.samp_freq.
[in]waveformPointer to a 1-D array of n samples.
[in]nNumber of samples in waveform.

◆ Dim()

int32_t knf::OnlinePitch::Dim ( ) const
Returns
The output feature dimension (= popts.Dim(), 3 by default).

◆ FrameShiftInSeconds()

float knf::OnlinePitch::FrameShiftInSeconds ( ) const
Returns
The frame shift in seconds.

◆ GetFrame()

std::vector< float > knf::OnlinePitch::GetFrame ( int32_t frame) const

Return the frame-th feature vector.

The frame is computed on demand and cached internally; calling this repeatedly for the same frame returns the same values (as long as frame < NumFramesReady()).

Parameters
[in]frameFrame index, must be < NumFramesReady().
Returns
Feature vector of size Dim().

◆ InputFinished()

void knf::OnlinePitch::InputFinished ( )

Tell the extractor no more waveform will be added; this flushes out the last frames and fixes the features of all frames.

◆ IsLastFrame()

bool knf::OnlinePitch::IsLastFrame ( int32_t frame) const
Returns
True if frame is the last frame (only true after InputFinished() has been called and this is the final frame).

◆ NumFramesReady()

int32_t knf::OnlinePitch::NumFramesReady ( ) const
Returns
The number of frames that are already computed and readable via GetFrame().

The documentation for this class was generated from the following file:
  • /home/runner/work/kaldi-native-fbank/kaldi-native-fbank/kaldi-native-fbank/csrc/feature-pitch.h