Delta features

Compute time derivatives on existing features

Uses the Kaldi implementation (see [kaldi-delta]):

Features –> DeltaPostProcessor –> Features


>>> import numpy as np
>>> from import Audio
>>> from shennong.processor.mfcc import MfccProcessor
>>> from import DeltaPostProcessor
>>> audio = Audio.load('./test/data/test.wav')
>>> mfcc = MfccProcessor().process(audio)

Initialize the delta processor and compute first and second order time derivatives of MFCC features:

>>> processor = DeltaPostProcessor(order=2)
>>> delta = processor.process(mfcc)

The resulting matrice is the concatenation of the original features, their first and second order derivatives:

>>> nmfcc = mfcc.shape[1]
>>> delta.shape[1] == nmfcc * 3
>>> original =[:, :nmfcc]
>>> np.array_equal(original,
>>> first_order =[:, nmfcc:2*nmfcc]
>>> second_order =[:, 2*nmfcc:]
>>> original.shape == first_order.shape == second_order.shape



class, window=2)[source]

Bases: shennong.postprocessor.base.FeaturesPostProcessor

property name

Name of the processor

property order

Order of delta computation


Get parameters for this processor.


deep (boolean, optional) – If True, will return the parameters for this processor and contained subobjects that are processors. Default to True.


params (mapping of string to any) – Parameter names mapped to their values.

property log

Processor logger

process_all(utterances, njobs=None, **kwargs)

Returns features processed from several input utterances

This function processes the features in parallel jobs.

  • utterances (:class`~shennong.uttterances.Utterances`) – The utterances on which to process features on.

  • njobs (int, optional) – The number of parallel jobs to run in background. Default to the number of CPU cores available on the machine.

  • **kwargs (dict, optional) – Extra arguments to be forwarded to the process method. Keys must be the same as for utterances.


features (FeaturesCollection) – The computed features on each input signal. The keys of output features are the keys of the input utterances.


ValueError – If the njobs parameter is <= 0 or if an entry is missing in optioanl kwargs.

set_logger(level, formatter='%(levelname)s - %(name)s - %(message)s')

Change level and/or format of the processor’s logger

  • level (str) – The minimum log level handled by the logger (any message above this level will be ignored). Must be ‘debug’, ‘info’, ‘warning’ or ‘error’.

  • formatter (str, optional) – A string to format the log messages, see By default display level and message. Use ‘%(asctime)s - %(levelname)s - %(name)s - %(message)s’ to display time, level, name and message.


Set the parameters of this processor.




ValueError – If any given parameter in params is invalid for the processor.

property window

Parameter controlling window for delta computation

The actual window size for each delta order is 1 + 2 * window. The behavior at the edges is to replicate the first or last frame.

property ndims

Dimension of the output features frames


Return the processors properties as a dictionary


Compute deltas on features with the specified options


features (Features, shape = [nframes, ncols]) – The input features on which to compute the deltas


deltas (Features, shape = [nframes, ncols * (order + 1)]) – The computed deltas with as much orders as specified. The output features are the concatenation of the input features and it’s time derivative at each orders.