maad.features.spectral_bandwidth
- maad.features.spectral_bandwidth(s, fs, nperseg=1024, roi=None, as_pandas=False, **kwargs)[source]
Compute the bandwith of the power spectrum. If a region of interest with time and spectral limits is provided, the spectral bandwidth is computed on the selection.
- Parameters:
- s1D array
Input audio signal
- fsfloat
Sampling frequency of audio signal
- 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_pandasbool
Return data as a pandas.Series. This is usefull when computing multiple features over a signal. Default is False.
- kwargsadditional keyword arguments
If window=’hann’, additional keyword arguments to pass to sound.spectrum.
- Returns:
- bandwidth_50float
Bandwidth 50% of the audio
- bandwidth_90float
Bandwidth 90% of the audio
Examples
>>> from maad import features, sound >>> s, fs = sound.load('../data/spinetail.wav') >>> bw_50, bw_90 = features.spectral_bandwidth(s, fs, nperseg=1024) >>> print("Bandwidth 50% : {:.4f} / Bandwidth 90% : {:.4f}".format(bw_50, bw_90)) Bandwidth 50% : 473.7305 / Bandwidth 90% : 3186.9141