卡尔曼滤波用于语音增强的一个经典代码matlab-副本.docx
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
卡尔曼滤波用于语音增强的一个经典代码matlab -副本function output=KalmanSignalDenoiser(Noisy,Clean,fs)
%OUTPUT=KALMANSIGNALDENOISER(NOISY,CLEAN,FS)
%this purpose of this function is to demonstrate the capability of
kalman % filter for denoising noisy speech (corrupted by white noise).
Kalman % filtering of noisy speech usually have two steps:
%1 . Estimating the AR parameters of speech segment
%2 . Filtering the segment
%There are different approaches for extracting AR parameters of
noisy % speech in the literature, however, in this function none is
implemented. % Clean speech signal should be provided for this purpose.
%
%ARGUMENTS
%NOISY : noise contaminated speech
%CLEAN : clean speech signal
%FS : Sampling frequency which should be the same for both signals
%
%Output is the denoised speech signal
%
%Required functions:
%SEGMENT
%Sep-04
%Esfandiar Zavarehei
W=fix(.025*fs); %Window length is 25 ms
SP=1; %Shift percentage is 40% (10ms) %Overlap-Add method works good with this value(.4)
SpecP=13;
Window=ones(W,1);
x=segment(Clean,W,SP,Window);
y=segment(Noisy,W,SP,Window);
n=segment(Noisy-Clean,W,SP,Window);
R=var(n);
H=[zeros(1,SpecP-1) 1];
G=H'; GGT=G*H;
FUpper=[zeros(SpecP-1,1) eye(SpecP-1)];
I=eye(SpecP);
[A Q]=lpc(x,SpecP);
P=diag(repmat(R(1),1,SpecP));
o=zeros(1,W*size(x,2));% allocating memory to the output in advance
save a lot of
computation time
o(1:SpecP)=y(1:SpecP,1)';
hwb = waitbar(0,'Please wait...','Name','Processing'); start=SpecP+1;
Sp=o(1:SpecP)';
t=SpecP+1;
for n=1:size(x,2)
waitbar(n/size(x,2),hwb,['Please wait... '
num2str(fix(100*n/size(x,2)))
' %'])
F=[FUpper; fliplr(-A(n,2:end))];
for i=start:W
S_=F*Sp;
e=y(i,n)-S_(end);%innovation
P_=F*P*F'+GGT*Q(n);
K=(P_*H')/(H*P_*H' + R(n));
SOut=S_+K*e;
o(t-SpecP+1:t)=SOut'; %Notice that the previous SpecP-1 output samples are
updated again
P=(I-K*H)*P_;
Sp=SOut;
t=t+1;
end
start=1;
end
close(hwb)
output=o;
function FormantTrack=FTrackSig(signal,fs)
%F=FTRACKSIG(S)
%Formant Tracking
% Inputs: S, signal, the speech signal with Motorola Format
and sampling
%frequency fs (default=16000 KHz)
%Outputs: F, FormantTrack is a matrix each row of which is a
track of one of
%the formants
%
%Important Variables in the program: There are several
important variables
%in the program:
%Main Function (FTrackSig)
%MaxFormantFreq : The maximum frequency of the formant % MaxBWFreq : The maximum BandWidth of the formant % SegLength: Number of samplein each frame,
%SP: Shift Percentage of frames, (1-SP is overlap percentage) % NumberOfFormants: The number of formants to be chosen % PreEmphFact:
the pre-emphasis factor
%fs: sampling frequency
%FormantCand function
%P: order of LPC model
%----------------------------------
%What does this program do:
%The speech signal is first choped into segments and the pre-
emphasize, % then windowed. Then the LPC Model for these segments are