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

Options for extracting frames from a waveform. More...

#include <feature-window.h>

Public Member Functions

int32_t WindowShift () const
 Return the window shift in samples.
int32_t WindowSize () const
 Return the window size in samples.
int32_t PaddedWindowSize () const
 Return the window size after zero-padding to a power of two, if round_to_power_of_two is true; otherwise the same as WindowSize().
std::string ToString () const
 Return the options as a string.

Public Attributes

float samp_freq = 16000
 Waveform data sample frequency (must match the waveform file, if specified there).
float frame_shift_ms = 10.0f
 Frame shift in milliseconds.
float frame_length_ms = 25.0f
 Frame length in milliseconds.
float dither = 0.00003f
 Amount of dithering, 0.0 means no dither.
float preemph_coeff = 0.97f
 Preemphasis coefficient.
bool remove_dc_offset = true
 Subtract mean of wave before FFT.
std::string window_type = "povey"
 Type of the windowing function; may be "hamming", "rectangular", "povey", "hanning", "hann", "sine", or "blackman".
bool round_to_power_of_two = true
 If true, round the window size to a power of two by zero-padding the input to the FFT.
float blackman_coeff = 0.42f
 Constant coefficient for the generalized Blackman window.
bool snip_edges = true
 If true, end effects are handled by outputting only frames that completely fit in the file, and the number of frames depends on the frame length.

Detailed Description

Options for extracting frames from a waveform.

This struct is the equivalent of kaldi's FrameExtractionOptions (src/feat/feature-window.h).

Used by:
Every feature computer: it is the frame_opts member of FbankOptions, MfccOptions, WhisperFeatureOptions, RawAudioSamplesOptions, and it is also used by ExtractWindow()/ProcessWindow()/NumFrames().
See also
FeatureWindowFunction, ExtractWindow, NumFrames, FbankOptions

Member Function Documentation

◆ PaddedWindowSize()

int32_t knf::FrameExtractionOptions::PaddedWindowSize ( ) const
inline

Return the window size after zero-padding to a power of two, if round_to_power_of_two is true; otherwise the same as WindowSize().

◆ ToString()

std::string knf::FrameExtractionOptions::ToString ( ) const
inline

Return the options as a string.

◆ WindowShift()

int32_t knf::FrameExtractionOptions::WindowShift ( ) const
inline

Return the window shift in samples.

◆ WindowSize()

int32_t knf::FrameExtractionOptions::WindowSize ( ) const
inline

Return the window size in samples.

Member Data Documentation

◆ blackman_coeff

float knf::FrameExtractionOptions::blackman_coeff = 0.42f

Constant coefficient for the generalized Blackman window.

◆ dither

float knf::FrameExtractionOptions::dither = 0.00003f

Amount of dithering, 0.0 means no dither.

Note: the default value 0.00003f here is equivalent to 1.0 in kaldi. If you turn this off, you should set the energy floor option, e.g. to 1.0 or 0.1.

◆ frame_length_ms

float knf::FrameExtractionOptions::frame_length_ms = 25.0f

Frame length in milliseconds.

◆ frame_shift_ms

float knf::FrameExtractionOptions::frame_shift_ms = 10.0f

Frame shift in milliseconds.

◆ preemph_coeff

float knf::FrameExtractionOptions::preemph_coeff = 0.97f

Preemphasis coefficient.

◆ remove_dc_offset

bool knf::FrameExtractionOptions::remove_dc_offset = true

Subtract mean of wave before FFT.

◆ round_to_power_of_two

bool knf::FrameExtractionOptions::round_to_power_of_two = true

If true, round the window size to a power of two by zero-padding the input to the FFT.

◆ samp_freq

float knf::FrameExtractionOptions::samp_freq = 16000

Waveform data sample frequency (must match the waveform file, if specified there).

◆ snip_edges

bool knf::FrameExtractionOptions::snip_edges = true

If true, end effects are handled by outputting only frames that completely fit in the file, and the number of frames depends on the frame length.

If false, the number of frames depends only on the frame shift, and we reflect the data at the ends.

◆ window_type

std::string knf::FrameExtractionOptions::window_type = "povey"

Type of the windowing function; may be "hamming", "rectangular", "povey", "hanning", "hann", "sine", or "blackman".

"povey" is a window made to be similar to Hamming but to go to zero at the edges: \( w[n] = (0.5 - 0.5 \cos(2\pi n/(N-1)))^{0.85} \).


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