maad.features.spectral_quantile
- maad.features.spectral_quantile(s, fs, q=[0.05, 0.25, 0.5, 0.75, 0.95], nperseg=1024, roi=None, as_pandas=False, amp=False, **kwargs)[source]
Compute the q-th quantile of the power spectrum. If a region of interest with time and spectral limits is provided, the q-th quantile is computed on the selection.
- Parameters:
- s1D array
Input audio signal
- fsfloat
Sampling frequency of audio signal
- qarray or float, optional
Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive. The defaul is [0.05, 0.25, 0.5, 0.75, 0.95].
- npersegint, optional
Length of segment to compute the FFT. The default is 1024.
- roipandas.Series, optional
Region of interest where peak frequency will be computed. Series must have a valid input format with index: min_t, min_f, max_t, max_f. The default is None.
- as_pandas: bool
Return data as a pandas.Series or pandas.DataFrame, when amp is False or True, respectively. Default is False.
- amp: bool
Enable quantiles amplitude output. Default is False.
- kwargsadditional keyword arguments
If window=’hann’, additional keyword arguments to pass to sound.spectrum.
- Returns:
- Pandas Series or Numpy array
Quantiles of power spectrum.
Examples
>>> from maad import sound, features >>> s, fs = sound.load('../data/spinetail.wav')
Compute the q-th quantile of the power spectrum
>>> qs = features.spectral_quantile(s, fs, [0.05, 0.25, 0.5, 0.75, 0.95], as_pandas=True) >>> print(qs) 0.05 6029.296875 0.25 6416.894531 0.50 6632.226562 0.75 6890.625000 0.95 9216.210938 dtype: float64
Compute the q-th quantile of the power spectrum and its amplitude
>>> qs = features.spectral_quantile(s, fs, [0.05, 0.25, 0.5, 0.75, 0.95], amp=True, as_pandas=True) >>> print(qs) freq amp 0.05 6029.296875 0.000007 0.25 6416.894531 0.000067 0.50 6632.226562 0.000087 0.75 6890.625000 0.000022 0.95 9216.210938 0.000004