audioflux.erb_spectrogram(X, num=128, radix2_exp=12, samplate=32000, low_fre=None, high_fre=None, window_type=WindowType.HANN, slide_length=None, style_type=SpectralFilterBankStyleType.SLANEY, normal_type=SpectralFilterBankNormalType.NONE, data_type=SpectralDataType.POWER)

Erb-scale spectrogram.


We recommend using the BFT class, you can use it more flexibly and efficiently.

X: np.ndarray [shape=(…, n)]

audio time series.

num: int

Number of erb frequency bins to generate, starting at low_fre.

radix2_exp: int


samplate: int

Sampling rate of the incoming audio.

low_fre: float

Lowest frequency.

high_fre: float or None

Highest frequency. Default is 16000 (samplate / 2).

window_type: WindowType

Window type for each frame.

See: type.WindowType

slide_length: int or None

Window sliding length.

If slide_length is None, then slide_length = fft_length / 4

style_type: SpectralFilterBankStyleType

Spectral filter bank style type. It determines the bank type of window.

see: type.SpectralFilterBankStyleType

normal_type: SpectralFilterBankNormalType

Spectral filter normal type. It determines the type of normalization.

See: type.SpectralFilterBankNormalType

data_type: SpectralDataType

Spectrogram data type.

It cat be set to mag or power. If you needs db type, you can set power type and then call the power_to_db method.

See: type.SpectralDataType

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

The matrix of ERB

fre_band_arr: np:ndarray [shape=(fre,)]

The array of frequency bands


Read 220Hz audio data

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

Extract spectrogram of dB

>>> low_fre = 0
>>> spec_arr, fre_band_arr = af.erb_spectrogram(audio_arr, samplate=sr, low_fre=low_fre)
>>> spec_dB_arr = af.utils.power_to_db(spec_arr)

Show spectrogram plot

>>> import matplotlib.pyplot as plt
>>> from audioflux.display import fill_spec
>>> import numpy as np
>>> # calculate x/y-coords
>>> audio_len = audio_arr.shape[-1]
>>> x_coords = np.linspace(0, audio_len/sr, spec_arr.shape[-1] + 1)
>>> y_coords = np.insert(fre_band_arr, 0, low_fre)
>>> fig, ax = plt.subplots()
>>> img = fill_spec(spec_dB_arr, axes=ax,
>>>                 x_coords=x_coords,
>>>                 y_coords=y_coords,
>>>                 x_axis='time', y_axis='log',
>>>                 title='Erb Spectrogram')
>>> fig.colorbar(img, ax=ax, format="%+2.0f dB")