Provides the PlpProcessor class to extract PLP features

Extract PLP (Perceptual Linear Predictive analysis of speech) from an audio signal. Uses the Kaldi implementation (see [Hermansky1990] and [kaldi-plp]).

Audio —> PlpProcessor —> Features


>>> from import Audio
>>> from shennong.features.processor.plp import PlpProcessor
>>> audio = Audio.load('./test/data/test.wav')

Initialize the PLP processor with some options. Options can be specified at construction, or after:

>>> processor = PlpProcessor()
>>> processor.sample_rate = audio.sample_rate
>>> processor.low_freq = 20
>>> processor.high_freq = -100  # nyquist - 100
>>> processor.compress_factor = 1/3

Compute the PLP features with the specified options, the output is an instance of Features:

>>> plp = processor.process(audio)
>>> type(plp)
<class 'shennong.features.features.Features'>
>>> plp.shape[1] == processor.num_ceps



Perceptual linear predictive (PLP) analysis of speech, H. Hermansky, Journal of the Acoustical Society of America, vol. 87, no. 4, pages 1738–1752 (1990)


class shennong.features.processor.plp.PlpProcessor(sample_rate=16000, frame_shift=0.01, frame_length=0.025, dither=1.0, preemph_coeff=0.97, remove_dc_offset=True, window_type='povey', round_to_power_of_two=True, blackman_coeff=0.42, snip_edges=True, num_bins=23, low_freq=20, high_freq=0, vtln_low=100, vtln_high=- 500, lpc_order=12, num_ceps=13, use_energy=True, energy_floor=0.0, raw_energy=True, compress_factor=0.3333333333333333, cepstral_lifter=22, cepstral_scale=1.0, htk_compat=False)[source]

Bases: shennong.features.processor.base.MelFeaturesProcessor

Perceptive linear predictive features

property name

Name of the processor

property blackman_coeff

Constant coefficient for generalized Blackman window

Used only if window_type is ‘blackman’

property dither

Amount of dithering

0.0 means no dither

property frame_length

Frame length in seconds

property frame_shift

Frame shift in seconds


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.


Return the processors properties as a dictionary

property high_freq

High cutoff frequency for mel bins in Hertz

If high_freq < 0, offset from the Nyquist frequency

property low_freq

Low cutoff frequency for mel bins in Hertz

property lpc_order

Order of LPC analysis in PLP computation

property num_bins

Number of triangular mel-frequency bins

The minimal number of bins is 3

property preemph_coeff

Coefficient for use in signal preemphasis

process(signal, vtln_warp=1.0)

Compute features with the specified options

Do an optional feature-level vocal tract length normalization (VTLN) when vtln_warp != 1.0.

  • signal (Audio, shape = [nsamples, 1]) – The input audio signal to compute the features on, must be mono

  • vtln_warp (float, optional) – The VTLN warping factor to be applied when computing features. Be 1.0 by default, meaning no warping is to be done.


features (Features, shape = [nframes, ndims]) – The computed features, output will have as many rows as there are frames (depends on the specified options frame_shift and frame_length).


ValueError – If the input signal has more than one channel (i.e. is not mono). If sample_rate != signal.sample_rate.

process_all(signals, njobs=None)

Returns features processed from several input signals

This function processes the features in parallel jobs.

  • signals (dict of :class``) – A dictionnary of input audio signals to process features on, where the keys are item names and values are audio signals.

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


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


ValueError – If the njobs parameter is <= 0

property remove_dc_offset

If True, subtract mean from waveform on each frame

property round_to_power_of_two

If true, round window size to power of two

This is done by zero-padding input to FFT

property sample_rate

Waveform sample frequency in Hertz

Must match the sample rate of the signal specified in process


Set the parameters of this processor.




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

property snip_edges

If true, output only frames that completely fit in the file

When True 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.


Returns the times label for the rows given by process()

property vtln_high

High inflection point in piecewise linear VTLN warping function

In Hertz. If vtln_high < 0, offset from high_freq

property vtln_low

Low inflection point in piecewise linear VTLN warping function

In Hertz

property window_type

Type of window

Must be ‘hamming’, ‘hanning’, ‘povey’, ‘rectangular’ or ‘blackman’

property num_ceps

Number of cepstra in PLP computation (including C0)

Should be smaller or equal to lpc_order + 1.

property use_energy

Use energy (instead of C0) for zeroth PLP feature

property energy_floor

Floor on energy (absolute, not relative) in PLP computation

property raw_energy

If true, compute energy before preemphasis and windowing

property compress_factor

Compression factor in PLP computation

property cepstral_lifter

Constant that controls scaling of PLPs

property cepstral_scale

Scaling constant in PLP computation

property htk_compat

If True, get closer to HTK PLP features

Put energy or C0 last.

Warning: Not sufficient to get HTK compatible features (need to change other parameters)

property ndims

Dimension of the output features frames