Fbank
Full doxygen reference (auto-generated from the headers): C++ API doxygen
Header: kaldi-native-fbank/csrc/feature-fbank.h — kaldi-compatible filter-bank features (equal to kaldi's compute-fbank-feats).
knf::FbankOptions opts;
opts.mel_opts.num_bins = 23;
knf::OnlineFbank fbank(opts);
fbank.AcceptWaveform(sample_rate, samples.data(), samples.size());
fbank.InputFinished();
std::vector<float> frame = fbank.GetFrame(0);
See Fbank for the kaldi flag mapping table.
API (doxygen)
-
struct FbankOptions
Options for computing filter-bank features.
This is kaldi's FbankOptions (src/feat/feature-fbank.h). It only includes things that can be done in a "stateless" way, i.e. it does not include energy max-normalization and it does not include delta computation.
See also
FbankComputer, FrameExtractionOptions, MelBanksOptions
Public Functions
-
inline FbankOptions()
Construct with the default options: 23 mel bins.
-
inline std::string ToString() const
Return the options as a string.
Public Members
-
FrameExtractionOptions frame_opts
Options for frame extraction; see FrameExtractionOptions.
-
MelBanksOptions mel_opts
Options for the mel filter banks; see MelBanksOptions.
-
bool use_energy = false
If true, append an extra dimension with energy to the filter banks.
-
float energy_floor = 0.0f
Floor on energy (absolute, not relative) in fbank computation.
Only makes a difference if use_energy is true; only necessary if frame_opts.dither is 0.0. Suggested values: 0.1 or 1.0.
-
bool raw_energy = true
If true, compute log energy before preemphasis and windowing; if false, compute it after preemphasis and windowing.
-
bool htk_compat = false
If true, put energy last (if using energy); if false, put energy first.
Warning: not sufficient to get HTK compatible features (need to change other parameters).
-
bool use_log_fbank = true
If true (default), produce log-filterbank; else linear.
-
bool use_log_floor = true
If true (default), use Kaldi's hard floor before the log, i.e.
\( \log(\max(e, \epsilon)) \). If false, use the additive guard \( \log(e + \epsilon) \), where \( e \) is the mel energy. NeMo models use the additive guard with eps = FLT_EPSILON / 2 (2^-24).
-
float eps = std::numeric_limits<float>::epsilon()
Value used by the log-zero guard selected by use_log_floor.
It defaults to FLT_EPSILON; NeMo models use FLT_EPSILON / 2 (2^-24, 5.9604644775390625e-08).
-
bool use_power = true
If true (default), use power in filterbank analysis; else magnitude.
-
inline FbankOptions()
-
using knf::OnlineFbank = OnlineGenericBaseFeature<FbankComputer>
Streaming filter-bank features; see FbankComputer.