Public Member Functions | |
OnlinePitchFeatureImpl (const PitchExtractionOptions &opts) | |
int32 | Dim () const |
BaseFloat | FrameShiftInSeconds () const |
int32 | NumFramesReady () const |
bool | IsLastFrame (int32 frame) const |
void | GetFrame (int32 frame, VectorBase< BaseFloat > *feat) |
void | AcceptWaveform (BaseFloat sampling_rate, const VectorBase< BaseFloat > &waveform) |
void | InputFinished () |
~OnlinePitchFeatureImpl () | |
OnlinePitchFeatureImpl (const OnlinePitchFeatureImpl &other) | |
Private Member Functions | |
int32 | NumFramesAvailable (int64 num_downsampled_samples, bool snip_edges) const |
This function works out from the signal how many frames are currently available to process (this is called from inside AcceptWaveform()). More... | |
void | ExtractFrame (const VectorBase< BaseFloat > &downsampled_wave_part, int64 frame_index, VectorBase< BaseFloat > *window) |
This function extracts from the signal the samples numbered from "sample_index" (numbered in the full downsampled signal, not just this part), and of length equal to window->Dim(). More... | |
void | RecomputeBacktraces () |
This function is called after we reach frame "recompute_frame", or when InputFinished() is called, whichever comes sooner. More... | |
void | UpdateRemainder (const VectorBase< BaseFloat > &downsampled_wave_part) |
This function updates downsampled_signal_remainder_, downsampled_samples_processed_, signal_sum_ and signal_sumsq_; it's called from AcceptWaveform(). More... | |
Private Attributes | |
PitchExtractionOptions | opts_ |
int32 | nccf_first_lag_ |
int32 | nccf_last_lag_ |
Vector< BaseFloat > | lags_ |
ArbitraryResample * | nccf_resampler_ |
LinearResample * | signal_resampler_ |
std::vector< PitchFrameInfo * > | frame_info_ |
std::vector< NccfInfo * > | nccf_info_ |
int32 | frames_latency_ |
Vector< BaseFloat > | forward_cost_ |
double | forward_cost_remainder_ |
std::vector< std::pair< int32, BaseFloat > > | lag_nccf_ |
bool | input_finished_ |
double | signal_sumsq_ |
sum-squared of previously processed parts of signal; used to get NCCF ballast term. More... | |
double | signal_sum_ |
sum of previously processed parts of signal; used to do mean-subtraction when getting sum-squared, along with signal_sumsq_. More... | |
int64 | downsampled_samples_processed_ |
downsampled_samples_processed is the number of samples (after downsampling) that we got in previous calls to AcceptWaveform(). More... | |
Vector< BaseFloat > | downsampled_signal_remainder_ |
This is a small remainder of the previous downsampled signal; it's used by ExtractFrame for frames near the boundary of two waveforms supplied to AcceptWaveform(). More... | |
Definition at line 574 of file pitch-functions.cc.
|
explicit |
Definition at line 715 of file pitch-functions.cc.
References VectorBase< Real >::Add(), OnlinePitchFeatureImpl::forward_cost_, OnlinePitchFeatureImpl::frame_info_, OnlinePitchFeatureImpl::frames_latency_, OnlinePitchFeatureImpl::lags_, PitchExtractionOptions::lowpass_cutoff, PitchExtractionOptions::lowpass_filter_width, PitchExtractionOptions::max_f0, PitchExtractionOptions::min_f0, OnlinePitchFeatureImpl::nccf_first_lag_, OnlinePitchFeatureImpl::nccf_last_lag_, OnlinePitchFeatureImpl::nccf_resampler_, PitchExtractionOptions::resample_freq, PitchExtractionOptions::samp_freq, kaldi::SelectLags(), OnlinePitchFeatureImpl::signal_resampler_, and PitchExtractionOptions::upsample_filter_width.
Definition at line 1037 of file pitch-functions.cc.
References OnlinePitchFeatureImpl::frame_info_, rnnlm::i, OnlinePitchFeatureImpl::nccf_info_, OnlinePitchFeatureImpl::nccf_resampler_, and OnlinePitchFeatureImpl::signal_resampler_.
OnlinePitchFeatureImpl | ( | const OnlinePitchFeatureImpl & | other | ) |
void AcceptWaveform | ( | BaseFloat | sampling_rate, |
const VectorBase< BaseFloat > & | waveform | ||
) |
Definition at line 1046 of file pitch-functions.cc.
References kaldi::ComputeCorrelation(), kaldi::ComputeNccf(), VectorBase< Real >::Dim(), OnlinePitchFeatureImpl::downsampled_samples_processed_, OnlinePitchFeatureImpl::ExtractFrame(), OnlinePitchFeatureImpl::forward_cost_, OnlinePitchFeatureImpl::forward_cost_remainder_, OnlinePitchFeatureImpl::frame_info_, OnlinePitchFeatureImpl::frames_latency_, OnlinePitchFeatureImpl::input_finished_, KALDI_ASSERT, KALDI_VLOG, OnlinePitchFeatureImpl::lag_nccf_, OnlinePitchFeatureImpl::lags_, PitchExtractionOptions::max_frames_latency, PitchExtractionOptions::nccf_ballast, PitchExtractionOptions::nccf_ballast_online, OnlinePitchFeatureImpl::nccf_first_lag_, OnlinePitchFeatureImpl::nccf_info_, OnlinePitchFeatureImpl::nccf_last_lag_, OnlinePitchFeatureImpl::nccf_resampler_, PitchExtractionOptions::NccfWindowShift(), PitchExtractionOptions::NccfWindowSize(), OnlinePitchFeatureImpl::NumFramesAvailable(), OnlinePitchFeatureImpl::opts_, PitchExtractionOptions::recompute_frame, OnlinePitchFeatureImpl::RecomputeBacktraces(), ArbitraryResample::Resample(), LinearResample::Resample(), Matrix< Real >::Resize(), MatrixBase< Real >::Row(), OnlinePitchFeatureImpl::signal_resampler_, OnlinePitchFeatureImpl::signal_sum_, OnlinePitchFeatureImpl::signal_sumsq_, PitchExtractionOptions::snip_edges, VectorBase< Real >::Sum(), OnlinePitchFeatureImpl::UpdateRemainder(), and kaldi::VecVec().
Referenced by OnlinePitchFeature::AcceptWaveform(), and OnlinePitchFeatureImpl::InputFinished().
|
inline |
Definition at line 578 of file pitch-functions.cc.
|
private |
This function extracts from the signal the samples numbered from "sample_index" (numbered in the full downsampled signal, not just this part), and of length equal to window->Dim().
It uses the data members downsampled_samples_discarded_ and downsampled_signal_remainder_, as well as the more recent part of the downsampled wave "downsampled_wave_part" which is provided.
downsampled_wave_part | One chunk of the downsampled wave, starting from sample-index downsampled_samples_discarded_. |
sample_index | The desired starting sample index (measured from the start of the whole signal, not just this part). |
window | The part of the signal is output to here. |
Definition at line 839 of file pitch-functions.cc.
References VectorBase< Real >::CopyFromVec(), VectorBase< Real >::Dim(), OnlinePitchFeatureImpl::downsampled_samples_processed_, OnlinePitchFeatureImpl::downsampled_signal_remainder_, rnnlm::i, OnlinePitchFeatureImpl::input_finished_, KALDI_ASSERT, OnlinePitchFeatureImpl::opts_, PitchExtractionOptions::preemph_coeff, VectorBase< Real >::Range(), VectorBase< Real >::SetZero(), and PitchExtractionOptions::snip_edges.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform().
BaseFloat FrameShiftInSeconds | ( | ) | const |
Definition at line 909 of file pitch-functions.cc.
References PitchExtractionOptions::frame_shift_ms, and OnlinePitchFeatureImpl::opts_.
Referenced by OnlinePitchFeature::FrameShiftInSeconds().
void GetFrame | ( | int32 | frame, |
VectorBase< BaseFloat > * | feat | ||
) |
Definition at line 921 of file pitch-functions.cc.
References VectorBase< Real >::Dim(), KALDI_ASSERT, OnlinePitchFeatureImpl::lag_nccf_, OnlinePitchFeatureImpl::lags_, and OnlinePitchFeatureImpl::NumFramesReady().
Referenced by OnlinePitchFeature::GetFrame().
void InputFinished | ( | ) |
Definition at line 928 of file pitch-functions.cc.
References OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::forward_cost_remainder_, OnlinePitchFeatureImpl::frame_info_, OnlinePitchFeatureImpl::frames_latency_, OnlinePitchFeatureImpl::input_finished_, KALDI_VLOG, PitchExtractionOptions::nccf_ballast_online, OnlinePitchFeatureImpl::opts_, PitchExtractionOptions::recompute_frame, OnlinePitchFeatureImpl::RecomputeBacktraces(), and PitchExtractionOptions::samp_freq.
Referenced by OnlinePitchFeature::InputFinished().
Definition at line 903 of file pitch-functions.cc.
References OnlinePitchFeatureImpl::input_finished_, KALDI_ASSERT, and OnlinePitchFeatureImpl::NumFramesReady().
Referenced by OnlinePitchFeature::IsLastFrame().
This function works out from the signal how many frames are currently available to process (this is called from inside AcceptWaveform()).
Note: the number of frames differs slightly from the number the old pitch code gave. Note: the number this returns depends on whether input_finished_ == true; if it is, it will "force out" a final frame or two.
Definition at line 768 of file pitch-functions.cc.
References OnlinePitchFeatureImpl::input_finished_, OnlinePitchFeatureImpl::nccf_last_lag_, PitchExtractionOptions::NccfWindowShift(), PitchExtractionOptions::NccfWindowSize(), and OnlinePitchFeatureImpl::opts_.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform().
int32 NumFramesReady | ( | ) | const |
Definition at line 913 of file pitch-functions.cc.
References OnlinePitchFeatureImpl::frames_latency_, KALDI_ASSERT, and OnlinePitchFeatureImpl::lag_nccf_.
Referenced by OnlinePitchFeatureImpl::GetFrame(), and OnlinePitchFeatureImpl::IsLastFrame().
|
private |
This function is called after we reach frame "recompute_frame", or when InputFinished() is called, whichever comes sooner.
It recomputes the backtraces for frames zero through recompute_frame, if needed because the average energy of the signal has changed, affecting the nccf ballast term. It works out the average signal energy from downsampled_samples_processed_, signal_sum_ and signal_sumsq_ (which, if you see the calling code, might include more frames than just "recompute_frame", it might include up to the end of the current chunk).
Definition at line 945 of file pitch-functions.cc.
References kaldi::ApproxEqual(), OnlinePitchFeatureImpl::downsampled_samples_processed_, OnlinePitchFeatureImpl::forward_cost_, OnlinePitchFeatureImpl::forward_cost_remainder_, OnlinePitchFeatureImpl::frame_info_, OnlinePitchFeatureImpl::frames_latency_, rnnlm::i, KALDI_ASSERT, KALDI_VLOG, OnlinePitchFeatureImpl::lag_nccf_, OnlinePitchFeatureImpl::lags_, PitchExtractionOptions::max_frames_latency, PitchExtractionOptions::nccf_ballast, PitchExtractionOptions::nccf_ballast_online, OnlinePitchFeatureImpl::nccf_info_, NccfInfo::nccf_pitch_resampled, PitchExtractionOptions::NccfWindowSize(), OnlinePitchFeatureImpl::opts_, PitchExtractionOptions::recompute_frame, OnlinePitchFeatureImpl::signal_sum_, and OnlinePitchFeatureImpl::signal_sumsq_.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), and OnlinePitchFeatureImpl::InputFinished().
|
private |
This function updates downsampled_signal_remainder_, downsampled_samples_processed_, signal_sum_ and signal_sumsq_; it's called from AcceptWaveform().
Definition at line 794 of file pitch-functions.cc.
References VectorBase< Real >::Dim(), OnlinePitchFeatureImpl::downsampled_samples_processed_, OnlinePitchFeatureImpl::downsampled_signal_remainder_, OnlinePitchFeatureImpl::frame_info_, rnnlm::i, KALDI_ASSERT, OnlinePitchFeatureImpl::nccf_last_lag_, PitchExtractionOptions::NccfWindowShift(), PitchExtractionOptions::NccfWindowSize(), OnlinePitchFeatureImpl::opts_, OnlinePitchFeatureImpl::signal_sum_, OnlinePitchFeatureImpl::signal_sumsq_, VectorBase< Real >::Sum(), and kaldi::VecVec().
Referenced by OnlinePitchFeatureImpl::AcceptWaveform().
|
private |
downsampled_samples_processed is the number of samples (after downsampling) that we got in previous calls to AcceptWaveform().
Definition at line 707 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::ExtractFrame(), OnlinePitchFeatureImpl::RecomputeBacktraces(), and OnlinePitchFeatureImpl::UpdateRemainder().
This is a small remainder of the previous downsampled signal; it's used by ExtractFrame for frames near the boundary of two waveforms supplied to AcceptWaveform().
Definition at line 711 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::ExtractFrame(), and OnlinePitchFeatureImpl::UpdateRemainder().
Definition at line 685 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::OnlinePitchFeatureImpl(), and OnlinePitchFeatureImpl::RecomputeBacktraces().
|
private |
Definition at line 688 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::InputFinished(), and OnlinePitchFeatureImpl::RecomputeBacktraces().
|
private |
Definition at line 668 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::InputFinished(), OnlinePitchFeatureImpl::OnlinePitchFeatureImpl(), OnlinePitchFeatureImpl::RecomputeBacktraces(), OnlinePitchFeatureImpl::UpdateRemainder(), and OnlinePitchFeatureImpl::~OnlinePitchFeatureImpl().
|
private |
|
private |
Definition at line 695 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::ExtractFrame(), OnlinePitchFeatureImpl::InputFinished(), OnlinePitchFeatureImpl::IsLastFrame(), and OnlinePitchFeatureImpl::NumFramesAvailable().
Definition at line 693 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::GetFrame(), OnlinePitchFeatureImpl::NumFramesReady(), and OnlinePitchFeatureImpl::RecomputeBacktraces().
Definition at line 654 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::GetFrame(), OnlinePitchFeatureImpl::OnlinePitchFeatureImpl(), and OnlinePitchFeatureImpl::RecomputeBacktraces().
|
private |
Definition at line 649 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), and OnlinePitchFeatureImpl::OnlinePitchFeatureImpl().
|
private |
Definition at line 675 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::RecomputeBacktraces(), and OnlinePitchFeatureImpl::~OnlinePitchFeatureImpl().
|
private |
Definition at line 651 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::NumFramesAvailable(), OnlinePitchFeatureImpl::OnlinePitchFeatureImpl(), and OnlinePitchFeatureImpl::UpdateRemainder().
|
private |
Definition at line 659 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::OnlinePitchFeatureImpl(), and OnlinePitchFeatureImpl::~OnlinePitchFeatureImpl().
|
private |
Definition at line 646 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::ExtractFrame(), OnlinePitchFeatureImpl::FrameShiftInSeconds(), OnlinePitchFeatureImpl::InputFinished(), OnlinePitchFeatureImpl::NumFramesAvailable(), OnlinePitchFeatureImpl::RecomputeBacktraces(), and OnlinePitchFeatureImpl::UpdateRemainder().
|
private |
Definition at line 664 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::OnlinePitchFeatureImpl(), and OnlinePitchFeatureImpl::~OnlinePitchFeatureImpl().
|
private |
sum of previously processed parts of signal; used to do mean-subtraction when getting sum-squared, along with signal_sumsq_.
Definition at line 703 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::RecomputeBacktraces(), and OnlinePitchFeatureImpl::UpdateRemainder().
|
private |
sum-squared of previously processed parts of signal; used to get NCCF ballast term.
Denominator is downsampled_samples_processed_.
Definition at line 699 of file pitch-functions.cc.
Referenced by OnlinePitchFeatureImpl::AcceptWaveform(), OnlinePitchFeatureImpl::RecomputeBacktraces(), and OnlinePitchFeatureImpl::UpdateRemainder().