Splice

Full doxygen reference (auto-generated from the headers): C++ API doxygen

Header: kaldi-native-fbank/csrc/feature-splice.h — the equivalent of kaldi's splice-feats (SpliceFrames).

knf::SpliceOptions opts;       // left_context=3, right_context=3
knf::MatrixF spliced = knf::SpliceFrames(feats, opts);

API (doxygen)

struct SpliceOptions

Options for SpliceFrames(); mirrors kaldi's splice-feats flags.

See also

SpliceFrames

Public Members

int32_t left_context = 3

Number of preceding frames to append (kaldi splice-feats --left-context).

int32_t right_context = 3

Number of following frames to append (kaldi splice-feats --right-context).

MatrixF knf::SpliceFrames(const MatrixF &feats, const SpliceOptions &opts)

Concatenate each frame with its left/right context neighbors.

This is kaldi's splice-feats (kaldi SpliceFrames in src/feat/feature-functions.cc), same arithmetic: for every frame index \( t \) the output row is

\[ y_t = [ x_{\max(0, t-L)}, \ldots, x_{\min(T-1, t+R)} ] \]

where \( L = \) opts.left_context, \( R = \) opts.right_context and \( T \) is the number of input frames. Edge frames are replicated: out-of-range indices clamp to the first/last frame. The output therefore has the same number of frames as the input and dim * (1 + L + R) dimensions.

knf::SpliceOptions opts;  // left=3, right=3 -> 7*D dims
knf::MatrixF spliced = knf::SpliceFrames(feats, opts);

See also

SpliceOptions

Used by:

Pipelines that build xvector/MFA-style features (mfcc -> cmvn -> splice -> lda).

Parameters:
  • feats -- [in] Feature matrix of size T x D (T > 0, D > 0).

  • opts -- [in] Contexts; see SpliceOptions.

Returns:

The spliced matrix of size T x (D * (1 + L + R)).