0% found this document useful (0 votes)
72 views6 pages

DTW 1

Search codes are search codes. Search codes are the search codes that are used to find terms. A search code is a code that is used to search for words. The search code is the search code for a word or phrase.

Uploaded by

suntosh_14
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views6 pages

DTW 1

Search codes are search codes. Search codes are the search codes that are used to find terms. A search code is a code that is used to search for words. The search code is the search code for a word or phrase.

Uploaded by

suntosh_14
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

www.pudn.com > DTWspeakerrecognize.rar > okk.

m, change:2006-09-05,size:7730b

Search codes
 

clear all clf


%--------------------------------------------------
¶Ëµã¼ì²â(Ö÷Òª»ùÓÚÄÜÁ¿ºÍ¹ýÁãÂÊ)
%------------------------------------------------¶ÌʱÄÜÁ¿
x0=wavread('zhang1');
T=256-80;
k=50;
y=zeros(1,k);
ETL=0.15;
ZT=2;
for n=1:T:length(x0)-256
E=0;
M=0;
for m=0:1:255
E=E+x0(n+m)^2;
M=M+abs(x0(n+m+1)-x0(n+m)); %Ò»Ö¡µÄ¹ýÁãÂÊ
end
En(fix(n/T)+1)=E;
Zn(fix(n/T)+1)=M;
end
% figure(1)
% subplot(211)
%plot(En)
% subplot(212)
% plot(Zn)
i=1;
for n=1:T:length(x0)-256
if( En(fix(n/T)+1)>=ETL&Zn(fix(n/T)+1)>=ZT)
y(i:i+T)=x0(n:n+T);
i=i+T;
end
end
% figure(1)
% subplot(211)
% plot(x0)
% title('Ô´ÓïÒôʾÒâͼ')
% xlabel('n')
% subplot(212)
%plot(y)
% title('¶Ëµã¼ì²âʾÒâͼ')
% xlabel('n')
%--------------Ô¤¼ÓÖØ----------------------
sn=y;
sn=sn';
for n=2:1:length(sn)
sn(n)=sn(n)-0.95*sn(n-1);
end
% figure(1)
% subplot(211)
% plot(x0)
% title('Ô´ÓïÒôʾÒâͼ')
% xlabel('n')
% subplot(212)
% plot(sn)
% title('¶Ëµã¼ì²âʾÒâͼ')
% xlabel('n')
%------------------------------------------------ÌáÈ¡LPCϵÊý£¨LDËã·¨£©
p=8; % Ñ¡ÕÛARÂ˲¨Æ÷½×ÊýΪ8
LPC=zeros(fix((length(sn)-256)/T),8);
x=zeros(1,256);
for m=1:T:length(sn)-256
for n=0:1:256
x(n+1)=sn(m+n);
end
r=xcorr(x,p,'biased'); % ¼ÆËãÐòÁеÄÓÐÆ«×ÔÏà¹Øº¯Êý
r=r(9:17);
a=zeros(1,p);
% ²ÉL-DËã·¨¼ÆËãARÂ˲¨Æ÷µÄ²ÎÊý
a(1)=-r(2)/r(1); % ¼ÆËãÒ»½×ARÂ˲¨Æ÷µÄϵÊý
pp=(1-abs(a(1))^2)*r(1); % ¼ÆËãÒ»½×Çé¿öϼ¤Àø²úÉúÐźŵŦÂÊ
for k=2:1:p;
a(k)=-(r(k+1)+dot(a(1:k-1),r(k:-1:2)))/pp;
a(1:k-1)=a(1:k-1)+a(k)*a(k-1:-1:1);
pp=(1-abs(a(k))^2)*pp;
end
LPC(fix(m/T)+1,1)=a(1);
LPC(fix(m/T)+1,2)=a(2);
LPC(fix(m/T)+1,3)=a(3);
LPC(fix(m/T)+1,4)=a(4);
LPC(fix(m/T)+1,5)=a(5);
LPC(fix(m/T)+1,6)=a(6);
LPC(fix(m/T)+1,7)=a(7);
LPC(fix(m/T)+1,8)=a(8);
end
%disp(LPC);
%------------------------------------------------------------Ãþ°å¾ØÕó
Myang=[ 0.1767 -0.9883 -0.3317 0.3116 0.2480 -0.1372
-0.0174 0.2604
0.3564 -0.8102 -0.6776 0.1607 0.4893 0.3502 0.0222
-0.0071
-0.0465 -0.5897 0.2295 0.2204 0.0458 0.2498 0.1924
-0.1609
-0.0908 -0.3772 0.7163 0.0963 -0.0610 0.3634 0.1895
-0.1947
0.1430 -0.1211 0.8548 0.3170 0.1023 0.2923 0.2831
0.0259
0.2194 -0.0026 1.0021 0.3900 0.1069 0.3104 0.2357
0.0538
0.0434 0.0280 1.0461 0.2623 0.0835 0.2552 0.2666
0.0024
-0.1820 0.0364 1.1029 0.0204 0.0004 0.2992 0.1901
-0.0866
-0.3195 -0.0670 1.0808 -0.1155 -0.1342 0.2984 0.0861
-0.1023
-0.2493 -0.1162 1.0732 0.0995 -0.2082 0.3092 0.1867
-0.0866
-0.2723 -0.1941 1.2464 -0.0244 -0.1918 0.3806 0.1504
-0.0379
-0.2086 -0.2642 1.2507 0.0940 -0.2412 0.3669 0.1980
-0.0070
-0.2555 -0.2999 1.3035 0.0217 -0.2806 0.4101 0.1950
-0.0171
-0.3116 -0.2992 1.3013 -0.0618 -0.1715 0.3787 0.1589
0.0972
-0.3928 -0.4003 1.3511 -0.1208 -0.3336 0.4133 0.1667
0.0187
-0.3972 -0.4795 1.3487 -0.0165 -0.4389 0.4123 0.1390
0.0352
-0.6973 -0.4468 1.4760 -0.3802 -0.4563 0.4785 0.0220
0.0209
-0.8227 -0.2877 1.2730 -0.4227 -0.2564 0.2150 0.1122
0.0207
-0.9045 -0.4028 1.3990 -0.5152 -0.2635 0.2035 0.0170
0.0851];
Mhua=[ -0.8065 -0.8897 1.0793 0.6142 -0.4540 -0.4615
0.2330 0.2042
-0.6447 -0.8791 0.8571 0.7036 -0.3373 -0.4203 0.1527
0.2032
-0.5716 -0.7320 0.7333 0.5482 -0.1683 -0.3343 0.1508
0.1135
-0.5151 -0.7255 0.6924 0.6346 -0.1569 -0.3792 0.1978
0.1303
-0.4886 -0.7870 0.6758 0.8107 -0.1916 -0.4927 0.2246
0.2252
-0.4697 -0.7741 0.6937 0.8056 -0.1448 -0.5239 0.2190
0.2939
-0.3364 -0.6965 0.7426 0.6606 -0.1196 -0.3478 0.2706
0.1855
-0.3289 -0.5819 0.6727 0.6698 0.0213 -0.4131 0.2405
0.2713
-0.3380 -0.4802 0.6924 0.6559 -0.0256 -0.3133 0.2558
0.2628
-0.4158 -0.5189 0.8215 0.6057 -0.1081 -0.3422 0.3509
0.2273
-0.3643 -0.6350 0.8310 0.7443 -0.1310 -0.4293 0.3788
0.2977
-0.3161 -0.5262 0.8620 0.5971 0.0293 -0.3170 0.2975
0.3417
-0.3634 -0.5973 0.9815 0.5158 0.0002 -0.2993 0.2593
0.3726
-0.3571 -0.5429 0.8804 0.6084 0.0135 -0.3763 0.3330
0.3572
-0.4377 -0.4837 0.9577 0.4677 -0.0355 -0.2583 0.2890
0.3239
-0.5731 -0.4700 1.0753 0.3619 -0.3095 -0.0913 0.3213
0.1653];
%-----------------------------------------------------------------------
-----------
%______________________________________________________DTWËã·¨Çó×îС¾àÀë
X=zeros(1,p);
Y=zeros(1,p);
C=zeros(1,p);
L=zeros(1,p);
[m,n]=size(LPC);
[q,s]=size(Myang);
X=LPC(1,:); %LPC¾ØÕóµÄµÚÒ»Ðи³ÓèX
Y=Myang(1,:); %one¾ØÕóµÄµÚÒ»Ðи³ÓèY
D(1)=sum(abs(X(1:1:p)-Y(1:1:p)));%¶ÔÓ¦µÚÒ»ÐÐ×ö²îµÄ¾ø¶ÔÖµµÄºÍ
t=1;
for i=2:1:m %ÐÐÑ»·
if t==q-1
X=LPC(i,:);
Y=Myang(t,:);
C=Myang(t+1,:);
H(1)=sum(abs(X(1:1:p)-Y(1:1:p)));
H(2)=sum(abs(X(1:1:p)-C(1:1:p)));
D(i)=min(H);
if D(i)==H(1)
t=t;
elseif D(i)==H(2)
t=t+1;
end
elseif t==q
X=LPC(i,:);
Y=Myang(q,:);
D(i)=sum(abs(X(1:1:p)-Y(1:1:p)));
else
X=LPC(i,:);
Y=Myang(t,:);
C=Myang(t+1,:);
L=Myang(t+2,:);
H(1)=sum(abs(X(1:1:p)-Y(1:1:p)));
H(2)=sum(abs(X(1:1:p)-C(1:1:p)));
H(3)=sum(abs(X(1:1:p)-L(1:1:p)));
D(i)=min(H);
if D(i)==H(1)
t=t;
elseif D(i)==H(2)
t=t+1;
elseif D(i)==H(3)
t=t+2;
end
end
end
TD1=sum(D);
F(1)=TD1;
disp(TD1);
%----------------------------------------------------------------------
X=zeros(1,p);
Y=zeros(1,p);
C=zeros(1,p);
L=zeros(1,p);
[m,n]=size(LPC);
[q,s]=size(Mhua);
X=LPC(1,:); %LPC¾ØÕóµÄµÚÒ»Ðи³ÓèX
Y=Mhua(1,:); %one¾ØÕóµÄµÚÒ»Ðи³ÓèY
D(1)=sum(abs(X(1:1:p)-Y(1:1:p))); %¶ÔÓ¦µÚÒ»ÐÐ×ö²îµÄ¾ø¶ÔÖµµÄºÍ
t=1;
for i=2:1:m %ÐÐÑ»·
if t==q-1
X=LPC(i,:);
Y=Mhua(t,:);
C=Mhua(t+1,:);
H(1)=sum(abs(X(1:1:p)-Y(1:1:p)));
H(2)=sum(abs(X(1:1:p)-C(1:1:p)));
D(i)=min(H);
if D(i)==H(1)
t=t;
elseif D(i)==H(2)
t=t+1;
end
elseif t==q
X=LPC(i,:);
Y=Mhua(q,:);
D(i)=sum(abs(X(1:1:p)-Y(1:1:p)));
else
X=LPC(i,:);
Y=Mhua(t,:);
C=Mhua(t+1,:);
L=Mhua(t+2,:);
H(1)=sum(abs(X(1:1:p)-Y(1:1:p)));
H(2)=sum(abs(X(1:1:p)-C(1:1:p)));
H(3)=sum(abs(X(1:1:p)-L(1:1:p)));
D(i)=min(H);
if D(i)==H(1)
t=t;
elseif D(i)==H(2)
t=t+1;
elseif D(i)==H(3)
t=t+2;
end
end
end
TD2=sum(D);
F(2)=TD2;
disp(TD2);
%----------------------------------------------------------------
%------------------------------------------------˵»°ÈËÉí·ÝÅжϲ¿·Ö
Q=min(F);
if Q==TD1
Q=1
else Q==TD2
Q=2
end

You might also like