kaldi-native-fbank C++ API
Kaldi-compatible feature extraction C++ API
Loading...
Searching...
No Matches
feature-pitch.h File Reference

kaldi-native-fbank/kaldi-native-fbank/csrc/feature-pitch.h More...

#include <stdint.h>
#include <memory>
#include <vector>
#include "kaldi-native-fbank/csrc/feature-matrix.h"
Include dependency graph for feature-pitch.h:

Go to the source code of this file.

Classes

struct  knf::PitchExtractionOptions
 Options for the raw pitch extraction stage (kaldi's PitchExtractionOptions). More...
struct  knf::ProcessPitchOptions
 Options for the pitch post-processing stage (kaldi's ProcessPitchOptions). More...
class  knf::OnlinePitch
 Streaming pitch extraction with post-processing (kaldi's OnlinePitchFeature + OnlineProcessPitch). More...

Namespaces

namespace  knf
 This file is part of kaldi-native-fbank.

Functions

MatrixF knf::ComputeAndProcessKaldiPitch (const PitchExtractionOptions &pitch_opts, const ProcessPitchOptions &process_opts, const float *wave, int32_t n)
 Batch pitch extraction (kaldi's ComputeAndProcessKaldiPitch).

Detailed Description

kaldi-native-fbank/kaldi-native-fbank/csrc/feature-pitch.h

This file is part of kaldi-native-fbank.

Pitch extraction (ported from kaldi's src/feat/pitch-functions.h).

Implements the pitch extraction method described in "A Pitch Extraction Algorithm Tuned for Automatic Speech Recognition", Pegah Ghahremani, Bagher BabaAli, Daniel Povey, Korbinian Riedhammer, Jan Trmal and Sanjeev Khudanpur, ICASSP 2014 (https://www.danielpovey.com/files/icassp2014_pitch.pdf).

The extraction happens in two stages, mirroring kaldi:

  1. Raw pitch (OnlinePitchFeature in kaldi): the waveform is downsampled, the normalized cross-correlation function (NCCF) is evaluated at log-spaced lags between \( 1/\mathrm{max\_f0} \) and \( 1/\mathrm{min\_f0} \), and a Viterbi search over the lags picks a per-frame lag \( L_t \); the raw output is the 2-dimensional \( (\mathrm{NCCF}_t, 1/L_t) \).
  2. Post-processing (OnlineProcessPitch in kaldi): turns the raw output into features — by default the 3-dimensional (POV, normalized-log-pitch, delta-pitch) used by kaldi's compute-and-process-kaldi-pitch-feats.

The streaming entry point is OnlinePitch; the batch entry point is ComputeAndProcessKaldiPitch, which reproduces the output of kaldi's compute-and-process-kaldi-pitch-feats bit-for-bit (with identical options and input).

pitch_opts.min_f0 = 50;
pitch_opts.max_f0 = 500;
knf::ProcessPitchOptions process_opts; // 3-dim output by default
knf::OnlinePitch pitch(pitch_opts, process_opts);
pitch.AcceptWaveform(pitch_opts.samp_freq, samples, n);
pitch.InputFinished();
for (int32_t t = 0; t != pitch.NumFramesReady(); ++t) {
std::vector<float> feat = pitch.GetFrame(t); // size == pitch.Dim()
}
Streaming pitch extraction with post-processing (kaldi's OnlinePitchFeature + OnlineProcessPitch).
Definition feature-pitch.h:311
Options for the raw pitch extraction stage (kaldi's PitchExtractionOptions).
Definition feature-pitch.h:84
float min_f0
Min F0 to search for (Hz). Kaldi --min-f0.
Definition feature-pitch.h:100
float max_f0
Max F0 to search for (Hz). Kaldi --max-f0.
Definition feature-pitch.h:103
float samp_freq
Waveform data sample frequency in Hz (must match the waveform).
Definition feature-pitch.h:87
Options for the pitch post-processing stage (kaldi's ProcessPitchOptions).
Definition feature-pitch.h:217
See also
PitchExtractionOptions, ProcessPitchOptions, OnlinePitch, ComputeAndProcessKaldiPitch, ResampleWaveform