Integrating spectrogram with the rest of the code