LPC Coding
LPC Coding
M=10; b=1; Now speech is divided into frames, each frames of size 30ms. fsize = 30e-3; frame_length = (fs .* fsize); N=frame_length-1; Then each frames are being analised through for-loop for getting the parameters that are : 1.Filter coefficients , 2.Pitch_period and 3.gain. for b=1 : frame_length : (length(x) - frame_length), y1=x(b:b+N); y = filter([1 -.9378], 1, y1); a=[zeros(10):zeros(10)]; Levinson-Durbin Algorithm: This algorithm is used to solve for filter coefficient.
z=xcorr(y); %Auto-correlation Function R=z( ( (length(z)+1) ./2 ) : length(z)); i=1; E(1)=R(1); for i=2:M+1 k(i)=0; for j=1:i-1 k(i)=k(i)+(a(j,i-1).*R(i-j+1))-R(i)./E(i-1); end a(i,i)=k(i); for j=1:i-1 a(j,i)=a(j,i-1)+(k(i).*a(i-j,i-1)); end E(i)=(1-(k(i).*k(i))).*E(i-1); end arra=a((2:i),i); count=length(arra); est_y = filter((-arra(2:end)),1,y); e = y - est_y;
Finding of pitch_period
period_min =fs.*2e-3; period_max =fs.*20e-3; %min period of a female voice frame = 2ms
[R_max , R_mid]=max(R); pitch_per_range = R ( R_mid + period_min : R_mid + period_max ); [R_max, R_mid] = max(pitch_per_range); pitch_period = R_mid + period_min;
Finding of Gain
temp= ( floor( length(e)./pitch_period ) .* pitch_period ); gain(b) = sqrt( sum(e(1:temp).^2 ));
end