Introduction
I am trying to find peaks in amplitude within a spectrogram I have produced that plots frequency against time and amplitude as the third axis.
I have looked through and attempted to code a solution using scipy.signal.find_peaks_cwt
however the official reference guide did not explain what was meant by the widths
parameter.
Question:
When finding peaks using scipy.signal.find_peaks_cwt
will it return the frequency-time coordinates? If not is there another library or method to use to return the coordinates of local maxima?
What is the widths
parameter within scipy.signal.find_peaks_cwt
?
As the scipy.signal.find_peaks_cwt
deals with arrays why do you still need to plot a spectrogram in order to find local maxima?
Here is the code i have been using to create the spectrogram:
import numpy as np
import matplotlib.pyplot as plt
import scipy.io.wavfile
from scipy import signal
def create_spectrogram(audio):
rate, data = scipy.io.wavfile.read(audio)
data_1D = data.flatten()
plt.specgram(data_1D, NFFT = 64, Fs = 64, noverlap=32)
plt.savefig("melody")
plt.show()
if __name__ == '__main__':
audio = "melody.WAV"
create_spectrogram(audio)
Here is the outputted Spectrogram:
Links:
scipy.signal.find_peaks_cwt
reference guide: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.find_peaks_cwt.html