I have a recorded audio signal that I would like to convert into spectrogram with the highest possible yield of information. The audio clips I am working with is about 30 ms long and contains frequencies between 20 Hz - 20 kHz. The sampling frequency used is 44.1 kHz.

What I have done:

In Python I have used the library librosa to create amplitude spectrograms. Here I have used the length of the signal as number of points for the FFT, hop length (number audio of frames between STFT columns) of 1 and window length (Each frame of audio is windowed by window()) of 64.

For reference, the code used to generate and display the spectrogram is as follows:

                         np.abs(librosa.stft(signal, len(signal), 1,64)) ** 2,
                         ref=1.0), y_axis='linear', sr=fs, cmap='coolwarm')

This seemed (visually) to give the best image result as seen below:


Is this as good as it gets?

I do have access to MATLAB as well, if someone can suggest a better method using that instead.


1 Answer 1


Good for what purpose? There are always trade-offs.

You can play with the color palette or function, or do local non-linear color selection.

You can try compositing/stacking multiple resolutions of spectrograms (both time and frequency) for higher contrast and perhaps more interesting appearances, but that process can add its own artifacts.

  • $\begingroup$ Thanks, didn’t think of that. For the purpose of echo detection. $\endgroup$
    – Jesper
    Jul 20, 2019 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.