spafe.features.psrcc#

  • Description : Phase based Spectral Root Cepstral Coefficients (PSRCCs) extraction algorithm implementation.

  • Copyright (c) 2019-2023 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>.

<<<<<<< HEAD spafe.features.psrcc.psrcc(sig: numpy.ndarray, fs: int = 16000, num_ceps: int = 13, pre_emph: bool = True, pre_emph_coeff: float = 0.97, window: Optional[spafe.utils.preprocessing.SlidingWindow] = None, nfilts: int = 26, nfft: int = 512, low_freq: Optional[float] = 0, high_freq: Optional[float] = None, scale: Literal['ascendant', 'descendant', 'constant'] = 'constant', gamma: float = - 0.14285714285714285, dct_type: int = 2, use_energy: bool = False, lifter: Optional[int] = None, normalize: Optional[int] = None, fbanks: Optional[numpy.ndarray] = None, conversion_approach: Literal['Oshaghnessy', 'Lindsay'] = 'Oshaghnessy') numpy.ndarray[source]#
======= spafe.features.psrcc.psrcc(sig: ndarray, fs: int = 16000, num_ceps: int = 13, pre_emph: bool = True, pre_emph_coeff: float = 0.97, window: Optional[SlidingWindow] = None, nfilts: int = 26, nfft: int = 512, low_freq: Optional[float] = 0, high_freq: Optional[float] = None, scale: Literal['ascendant', 'descendant', 'constant'] = 'constant', gamma: float = - 0.14285714285714285, dct_type: int = 2, use_energy: bool = False, lifter: Optional[int] = None, normalize: Optional[int] = None, fbanks: Optional[ndarray] = None, conversion_approach: Literal['Oshaghnessy', 'Lindsay'] = 'Oshaghnessy') ndarray[source]# >>>>>>> b99f17f0b60dc3a996941ffe07f8c10913292e02

Compute the Phase-based Spectral Root Cepstral Coefficients (PSRCC) from an audio signal according to [Tapkir].

Parameters
  • sig (numpy.ndarray) – a mono audio signal (Nx1) from which to compute features.

  • fs (int) – the sampling frequency of the signal we are working with. (Default is 16000).

  • num_ceps (int) – number of cepstra to return. (Default is 13).

  • pre_emph (bool) – apply pre-emphasis if 1. (Default is True).

  • pre_emph_coeff (float) – pre-emphasis filter coefficient. (Default is 0.97).

  • window (SlidingWindow) – sliding window object. (Default is None).

  • nfilts (int) – the number of filters in the filter bank. (Default is 40).

  • nfft (int) – number of FFT points. (Default is 512).

  • low_freq (float) – lowest band edge of mel filters (Hz). (Default is 0).

  • high_freq (float) – highest band edge of mel filters (Hz). (Default is samplerate / 2).

  • scale (str) – monotonicity behavior of the filter banks. (Default is “constant”).

  • gamma (float) – power coefficient for resulting energies (Default -1/7).

  • dct_type (int) – type of DCT used. (Default is 2).

  • use_energy (bool) – overwrite C0 with true log energy. (Default is False).

  • lifter (int) – apply liftering if specified. (Default is None).

  • normalize (str) – apply normalization if specified. (Default is None).

  • fbanks (numpy.ndarray) – filter bank matrix. (Default is None).

  • conversion_approach (str) – mel scale conversion scale. (Default is “Oshaghnessy”).

Returns

2d array of PSRCC features (num_frames x num_ceps)

Return type

(numpy.ndarray)

Tip

  • scale : can take the following options [“constant”, “ascendant”, “descendant”].

  • dct : can take the following options [1, 2, 3, 4].

  • normalize : can take the following options [“mvn”, “ms”, “vn”, “mn”].

  • conversion_approach : can take the following options [“Oshaghnessy”, “Lindsay”]. Note that the use of different options than the default can lead to unexpected behavior/issues.

Note

../_images/psrccs.png

Architecture of phase based spectral root cepstral coefficients extraction algorithm.#

Examples

from scipy.io.wavfile import read
from spafe.features.psrcc import psrcc
from spafe.utils.preprocessing import SlidingWindow
from spafe.utils.vis import show_features

# read audio
fpath = "../../../tests/data/test.wav"
fs, sig = read(fpath)

# compute psrccs
psrccs  = psrcc(sig,
                fs=fs,
                pre_emph=1,
                pre_emph_coeff=0.97,
                window=SlidingWindow(0.03, 0.015, "hamming"),
                nfilts=128,
                nfft=2048,
                low_freq=0,
                high_freq=8000,
                normalize="mvn")

# visualize features
show_features(psrccs, "Phase based Spectral Root Cepstral Coefficients", "PSRCC Index", "Frame Index")
../_images/psrcc-1.png