正确加窗语音信号
Windowing a speech signal correctly
我正在对语音信号应用汉明 window 以执行音频声音的特征提取。
我将信号分成帧的方式是否正确?我应该使用 window 重叠吗?
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')
信号图和 windows:
放大:
谢谢。
基于我对使用 buffer
和 bsxfun
的评论。考虑以下代码,
[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);
我正在对语音信号应用汉明 window 以执行音频声音的特征提取。
我将信号分成帧的方式是否正确?我应该使用 window 重叠吗?
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')
信号图和 windows:
放大:
谢谢。
基于我对使用 buffer
和 bsxfun
的评论。考虑以下代码,
[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);