XXCC

class audioflux.XXCC(num)

Cepstrum coefficients, supports all spectrum types.

Parameters
num: int

Number of frequency bins to generate. It must be the same as the num parameter of the transformation (same as the spectrogram matrix).

Examples

Get a 220Hz’s audio file

>>> import audioflux as af
>>> sample_path = af.utils.sample_path('220')
>>> audio_arr, sr = af.read(sample_path)

Create BFT object and extract mel spectrogram

>>> import numpy as np
>>> from audioflux.type import SpectralFilterBankScaleType, SpectralDataType
>>> bft_obj = af.BFT(num=128, radix2_exp=12, samplate=sr,
>>>                  scale_type=SpectralFilterBankScaleType.MEL,
>>>                  data_type=SpectralDataType.POWER)
>>> spec_arr = bft_obj.bft(audio_arr)
>>> spec_arr = np.abs(spec_arr)

Create XXCC object and extract mfcc

>>> xxcc_obj = af.XXCC(bft_obj.num)
>>> xxcc_obj.set_time_length(time_length=spec_arr.shape[1])
>>> mfcc_arr = xxcc_obj.xxcc(spec_arr)

Display MFCC

>>> import matplotlib.pyplot as plt
>>> from audioflux.display import fill_spec
>>> audio_len = audio_arr.shape[-1]
>>> fig, ax = plt.subplots()
>>> img = fill_spec(mfcc_arr, axes=ax,
>>>           x_coords=bft_obj.x_coords(audio_len), x_axis='time',
>>>           title='MFCC')
>>> fig.colorbar(img, ax=ax)
../_images/xxcc-1.png

Methods

set_time_length(time_length)

Set time length

xxcc(m_data_arr[, cc_num, rectify_type])

Get XX cepstral coefficients.

xxcc_standard(m_data_arr, energy_arr[, ...])

Get XX cepstral coefficients standard

set_time_length(time_length)

Set time length

Parameters
time_length: int
xxcc(m_data_arr, cc_num=13, rectify_type=CepstralRectifyType.LOG)

Get XX cepstral coefficients.

Parameters
m_data_arr: np.ndarray [shape=(…, fre, time)]

Spectrogram data.

cc_num: int

xxcc num, usually set to 13, 20 or 40

rectify_type: CepstralRectifyType
Returns
out: np.ndarray [shape=(…, cc_num, time)]

cc data

xxcc_standard(m_data_arr, energy_arr, cc_num=13, delta_window_length=9, energy_type=CepstralEnergyType.REPLACE, rectify_type=CepstralRectifyType.LOG)

Get XX cepstral coefficients standard

Parameters
m_data_arr: np.ndarray [shape=(…, fre, time)]

Spectrogram data.

energy_arr: np.ndarray [shape=(…, time)]

energy data.

cc_num: int

xxcc num, usually set to 13, 20 or 40

delta_window_length: int

must odd>=3

energy_type: CepstralEnergyType
rectify_type: CepstralRectifyType
Returns
coe_arr: np.ndarray [shape=(…, cc_num, time)]
m_delta_arr1: np.ndarray [shape=(…, cc_num, time)]
m_delta_arr2: np.ndarray [shape=(…, cc_num, time)]