# High resolution spectrograms

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:

plt.figure()
librosa.display.specshow(librosa.power_to_db(
np.abs(librosa.stft(signal, len(signal), 1,64)) ** 2,
ref=1.0), y_axis='linear', sr=fs, cmap='coolwarm')
plt.axis("off")
plt.savefig(SAVEDIR_spec_cw+"spec_"+str(i)+".png")
plt.close()


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

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.

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