A spectrogram, or sonogram, is a visual representation of the spectrum of frequencies in a sound, at each time. Spectrograms are also called spectral waterfalls, voiceprints, or voicegrams. Spectrograms are used extensively in the development of the fields of music, sonar, radar, and speech processing, seismology, etc.
Questions tagged [spectrogram]
502 questions
31
votes
5 answers
How to convert a .wav file to a spectrogram in python3
I am trying to create a spectrogram from a .wav file in python3.
I want the final saved image to look similar to this image:
I have tried the following:
This stack overflow post:
Spectrogram of a wave file
This post worked, somewhat. After…

Sreehari R
- 919
- 4
- 11
- 21
24
votes
4 answers
Spectrogram C++ library
For my current project in C++ / Qt I need a library (LGPL is preferred) which can calculate a spectrogram from a signal ( basically an array of doubles ). I already use Qwt for the GUI part.
Any suggestions?
Thanks.

gregseth
- 12,952
- 15
- 63
- 96
22
votes
3 answers
Difference between mel-spectrogram and an MFCC
I'm using the librosa library to convert music segments into mel-spectrograms to use as inputs for my neural network, as shown in the docs here.
How is this different from MFCCs, if at all? Are there any advantages or disadvantages to using either?

monadoboi
- 1,651
- 3
- 16
- 26
20
votes
4 answers
MATLAB 'spectrogram' params
I am a beginner in MATLAB and I should perform a spectral analysis of an EEG signal drawing the graphs of power spectral density and spectrogram. My signal is 10 seconds long and a sampling frequency of 160 Hz, a total of 1600 samples and have some…

rflmota
- 349
- 2
- 5
- 7
16
votes
2 answers
How do I plot a spectrogram the same way that pylab's specgram() does?
In Pylab, the specgram() function creates a spectrogram for a given list of amplitudes and automatically creates a window for the spectrogram.
I would like to generate the spectrogram (instantaneous power is given by Pxx), modify it by running an…

danmcardle
- 2,079
- 2
- 17
- 25
15
votes
2 answers
scipy.signal.spectrogram compared to matplotlib.pyplot.specgram
The following code generates a spectrogram using either scipy.signal.spectrogram or matplotlib.pyplot.specgram.
The color contrast of the specgram function is, however, rather low.
Is there a way to increase it?
import numpy as np
from scipy import…

NicolasBourbaki
- 853
- 1
- 6
- 19
15
votes
1 answer
What is a spectrogram and how do I set its parameters?
I am trying to plot the spectrogram of my time domain signal given:
N=5000;
phi = (rand(1,N)-0.5)*pi;
a = tan((0.5.*phi));
i = 2.*a./(1-a.^2);
plot(i);
spectrogram(i,100,1,100,1e3);
The problem is I don't understand the parameters and what values…

benzene
- 165
- 1
- 1
- 6
13
votes
1 answer
Creating spectrogram from .wav using FFT in java
After researching and a lot of trials-and-errors, I have come to a point that I can construct a spectrogram which I think it has element of rights and wrongs.
1. First, I read .wav file into a byte array and extract only the data part.
2. I convert…

Aung
- 253
- 1
- 5
- 15
13
votes
5 answers
Converting an FFT to a spectogram
I have an audio file and I am iterating through the file and taking 512 samples at each step and then passing them through an FFT.
I have the data out as a block 514 floats long (Using IPP's ippsFFTFwd_RToCCS_32f_I) with real and imaginary…

Goz
- 61,365
- 24
- 124
- 204
12
votes
3 answers
Get a spectrum of frequencies from WAV/RIFF using Linux command line
How to generate a file that contains the spectrum of frequencies of a WAV/RIFF sound file?
I would like to use the Linux command line.
I know the cool SoX function to generate PNG spectrograms:
sox sound.wav -n spectrogram
But I do not need a…

zsedc
- 141
- 1
- 1
- 7
11
votes
3 answers
Wrong spectrogram when using scipy.signal.spectrogram
When I use the plt.specgram from matplotlib by using the following code, the spectrogram generated is correct
import matplotlib.pyplot as plt
from scipy import signal
from scipy.io import wavfile
import numpy as np
sample_rate, samples =…

Raven Cheuk
- 2,903
- 4
- 27
- 54
11
votes
2 answers
How to handle dynamic input size for audio spectrogram used in CNN?
A lot of articles are using CNNs to extract audio features. The input data is a spectrogram with two dimensions, time and frequency.
When creating an audio spectrogram, you need to specify the exact size of both dimensions. But they are usually not…

Luv
- 263
- 3
- 9
11
votes
3 answers
generating correct spectrogram using fftw and window function
For a project I need to be able to generate a spectrogram from a .WAV file. I've read the following should be done:
Get N (transform size) samples
Apply a window function
Do a Fast Fourier Transform using the samples
Normalise the output
Generate…

Boedy
- 6,647
- 1
- 21
- 24
10
votes
1 answer
Create a spectrogram in Node.js
How can I extract the time/frequency/amplitude information from a WAV (or AIFF)? I want a spectrogram as a an array, e.g.
[
[ // 1st sample, time
[frequency1_t1, amplitude_f1t1], [frequency2_t1, amplitude_f2t1], ...
],
[ // 2nd sample,…

Andi Giga
- 3,744
- 9
- 38
- 68
10
votes
1 answer
Calculating spectrogram of .wav files in python
I am trying to calculate the spectrogram out of .wav files using Python. In an effort to do so, I am following the instructions that could be found in here. I am firstly read .wav files using librosa library. The code found in the link works…

Jose Ramon
- 5,572
- 25
- 76
- 152