# Window length in matplotlib's specgram

In the paper about speaker verification I can read that

Two quantities have to be set: the length of the window and the shift between two consecutive windows. For the length of the window, two values are most often used: 20 milliseconds and 30 milliseconds. [...] For the delay, the value is chosen in order to have an overlap between two consecutive windows; 10 milliseconds is very often used.

and later

Once an FFT algorithm has been chosen, the only parameter to fix for the FFT calculation is the number of points for the calculation itself. This number N is usually a power of 2 which is greater than the number of points in the window, classically 512.

However, in the matplotlib's specgram I can only see NFFT and noverlap parameters which, according to the documentation, correspond to the second quotation.

How can I then set the window's length or what is the default value of it?

## 2 Answers

You can set the window length either by setting NFFT = window_length_in_seconds * sample_rate, or, for shorter windows than this, by using a window function of length NFFT where a portion of that length is zero padded.

You'd generally do the FFT without zero padding, i.e. window size == FFT length.

Having an FFT larger than the window leads to an interpolation, but doesn't add any information to the signal, and that's only useful in certain cases – maybe the paper presents one such case.

• So it means that by default the window's length is 256 ms in matplotlib's specgram? – Colonder Aug 26 '18 at 12:30
• no. The default window length is in samples, not in seconds! – Marcus Müller Aug 26 '18 at 12:31
• So 256 samples over the entire signal? Say, in 10 s signal it would roughly mean that a sample is collected each 40 ms? – Colonder Aug 26 '18 at 12:36
• I don't know how your signal is sampled, so your question can't be answered. Stop thinking in times. Start thinking in samples :) – Marcus Müller Aug 26 '18 at 12:37