0
$\begingroup$

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:

spectrogram

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.

$\endgroup$
0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Thanks, didn’t think of that. For the purpose of echo detection. $\endgroup$ – Jesper Jul 20 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.