vocalpy.spectrogram

Contents

vocalpy.spectrogram#

vocalpy.spectrogram(sound: Sound, n_fft: int = 512, hop_length: int = 64, method='librosa-db', params: Mapping | Params | None = None) Spectrogram[source]#

Get a spectrogram from audio.

This is a convenience function that takes an instance of vocalpy.Sound and returns an instance of vocalpy.Spectrogram. The vocalpy.Spectrogram.data will be a spectral representation computed according to the specified method.

Parameters:
soundvocalpy.Sound

Audio used to compute spectrogram.

n_fftint

Length of the frame used for the Fast Fourier Transform, in number of audio samples. Default is 512.

hop_lengthint

Number of audio samples to “hop” for each frame whe computing the Fast Fourier Transform. Smaller values increase the number of columns in the spectrogram, without affecting the frequency resolution of the STFT.

methodstr

Name of method. Default is ‘librosa-db’.

paramsvocalpy.Params, mapping, None

A dictionary-like mapping from function parameter names to argument values.

Methods

* `’librosa-db`’: dB-scaled spectrogram

Equivalent to calling S = librosa.STFT(sound.data) and then S = librosa.amplitude_to_db(np.abs(S)).

* ``’sat-multitaper``: multi-taper spectrogram computed the same way

that the Sound Analysis Toolbox for Matlab (SAT) does.

* ``’soundsig-spectro``: dB-scaled spectrogram

computed with Gaussian window; replicates the result of the method soundsig.BioSound.spectroCalc in the soundsig package.

Returns:
spectvocalpy.Spectrogram

A vocalpy.Spectrogram instance computed according to method