maad.features.peak_frequency
- maad.features.peak_frequency(s, fs, method='best', nperseg=1024, roi=None, amp=False, as_pandas=False, **kwargs)[source]
Compute the peak frequency for audio signal. The peak frequency is the frequency of maximum power. If a region of interest with time and spectral limits is provided, the peak frequency is computed on the selection.
- Parameters:
- s1D array
Input audio signal
- fsfloat
Sampling frequency of audio signal
- method{‘fast’, ‘best’}, optional
Method used to compute the peak frequency. The default is ‘best’.
- 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.
- kwargsadditional keyword arguments
Additional keyword arguments to pass to sound.spectrum.
- Returns:
- peak_freqfloat
Peak frequency of audio segment.
- amp_peak_freqfloat
Amplitud of the peak frequency of audio segment.
Examples
>>> from maad import features, sound >>> s, fs = sound.load('../data/spinetail.wav')
Compute peak frequency
>>> peak_freq, peak_freq_amp = features.peak_frequency(s, fs, amp=True) >>> print('Peak Frequency: {:.5f}, Amplitude: {:.5f}'.format(peak_freq, peak_freq_amp)) Peak Frequency: 6634.16016, Amplitude: 0.00013