user4061624
user4061624

Reputation:

Windowing a speech signal correctly

I'm applying a Hamming window to a speech signal in order to perform features extraction of the audio sound.

The way I'm splitting the signal into frames is correct? Should I use a window overlap?

Here's my attempt using MATLAB:

clear
close all

[data,fs] = audioread('speech_demo.wav');

timeWindow   = 20e-3;
lengthWindow = round(timeWindow*fs); % number of samples per window

L       = lengthWindow;
w_start = 0;
w_end   = lengthWindow;
j = 1;
for k = 1:round(length(data)/lengthWindow)

    x = w_start:w_end-1;
    hold on
    plot(x,hann(lengthWindow),'r:');
    plot(x,data(x+1),'k.-')
    plot(x,data(x+1).*hamming(lengthWindow),'m.-')
    wSignal(j:L*k,:) = data(x+1).*hamming(lengthWindow);

    w_start = w_start + L;
    w_end   = w_start + L;
    j       = L*k+1;

end
set(gcf,'color','w')

The plot of the signals and the windows: enter image description here

A zoom in: enter image description here

Thank you.

Upvotes: 0

Views: 1616

Answers (1)

kedarps
kedarps

Reputation: 861

Based on my comment on using buffer and bsxfun. Consider following code,

[y,Fs] = audioread('someAudioFile.wav');

timeWindow   = 20e-3;
lengthWindow = round(timeWindow*Fs); % number of samples per window

% third argument specifies the number of overlapping samples
yBuffer = buffer(y, lengthWindow, round(lengthWindow*0.2));
hammWin = hamming(lengthWindow);

yBufferWindowed = bsxfun(@times, yBuffer, hammWin);

Upvotes: 1

Related Questions