spafe.utils.cepstral#

  • Description : Power-Normalized Cepstral Coefficients (PNCCs) extraction algorithm implementation.

  • Copyright (c) 2019-2024 Ayoub Malek. This source code is licensed under the terms of the BSD 3-Clause License. For a copy, see <https://github.com/SuperKogito/spafe/blob/master/LICENSE>.

spafe.utils.cepstral.normalize_ceps(x: ndarray, normalization_type: typing_extensions.Literal[mvn, ms, vn, mn] = 'mvn') ndarray[source]#

Apply normalization to array.

Parameters
  • x (numpy.ndarray) – array of information.

  • normalizaation_type (str) – type of normalization to apply:

Returns

(numpy.ndarray) normalized array.

Note

possible options for normalization_type are:

  • “mvn”Mean Variance Normalisation.
    \[x^{\prime}=\frac{x-\operatorname{average}(x)}{\operatorname{std}(x)}\]
  • “ms”Mean Substraction: Centering.
    \[x^{\prime} = x - \operatorname{average}(x)\]
  • “vn”Variance Normalisation: Standardization.
    \[x^{\prime} = \frac{x}{\operatorname{std}(x)}\]
  • “mn”Mean normalization.
    \[x^{\prime} = \frac{x - \operatorname{average}(x)}{ \max(x) - \min(x)}\]

where \(\operatorname{std}(x)\) is the standard deviation.

spafe.utils.cepstral.lifter_ceps(ceps: ndarray, lift: int = 3) ndarray[source]#

Apply a cepstral lifter the the matrix of cepstra. This has the effect of increasing the magnitude of the high frequency DCT coeffs. the liftering is implemented as in [Ellis-plp].

Parameters
  • ceps (numpy.ndarray) – the matrix of mel-cepstra, will be numframes * numcep in size.

  • lift (int) – the liftering coefficient to use. (Default is 3).

Returns

(numpy.ndarray) liftered cepstra.

Note

  • The liftering is applied to matrix of cepstra (one per column).

  • If the lift is positive (Use values smaller than 10 for meaningful results), then the liftering uses the exponent. However, if the lift is negative (Use integers), then the sine curve liftering is used.

References

Ellis-plp

: Ellis, D. P. W., 2005, PLP and RASTA and MFCC, and inversion in Matlab, <http://www.ee.columbia.edu/~dpwe/resources/matlab/rastamat/>

spafe.utils.cepstral.deltas(x: ndarray, w: int = 9) ndarray[source]#

Calculate the deltas (derivatives) of an input sequence with a W-points window (W odd, default 9) using a simple linear slope. This mirrors the delta calculation performed in feacalc etc. Each row of X is filtered separately.

Parameters
  • x (numpy.ndarray) – input sequence

  • w (int) – window size to use in the derivatives calculation. (Default is 9).

Returns

(numpy.ndarray) 2d-arrays containing the derivatives values.