clear all
for i=1:30
fname=sprintf('D:\\study\\音频采样\\speechwithmusic22050\\%d.wav',i);
x=wavread(fname);
x=x(:,1);
[c,l]=wavedec(x,3,'db4');
ca=appcoef(c,l,'db4',3);%近似系数
x=ca;
enframex=enframe(x,128,64);%对信号x分帧处理,每帧有128个采样点,相邻帧之间有50%的叠加率
[row,col]=size(enframex);%返回行,列,每一行代表一帧,每一列表示1到128个采样点
A=abs(enframex).^2;
energy=zeros(row,1);
for j=1:row
energy(j)=sum(A(j,:));
end
for j=1:row
s(j)=0;
s(j)=s(j)+energy(j).*log10(energy(j));
end
Err=-s;swm(i)=0;
for k=1:row
if Err(1,k) swm(i)=swm(i)+1;
end
end
swmshangbi(1,i)=swm(i)/row;
end
swmshangbi
clear
for i=1:30
fname=sprintf('D:\\study\\音频采样\\speech22050hz\\%d.wav',i);
x=wavread(fname);
x=x(:,1);
[c,l]=wavedec(x,3,'db4');
ca=appcoef(c,l,'db4',3);%近似系数
x=ca;
enframex=enframe(x,128,64);%对信号x分帧处理,每帧有128个采样点,相邻帧之间有50%的叠加率
[row,col]=size(enframex);%返回行,列,每一行代表一帧,每一列表示1到128个采样点
A=abs(enframex).^2;
energy=zeros(row,1);
for j=1:row
energy(j)=sum(A(j,:));
end
for j=1:row
s(j)=0;
s(j)=s(j)+energy(j).*log10(energy(j));
end
Err=-s;speech(i)=0;
for k=1:row
if Err(1,k) speech(i)=speech(i)+1;
end
end
speechshangbi(1,i)=speech(i)/row;
end
speechshangbi
clear
for i=1:30
fname=sprintf('D:\\study\\音频采样\\music22050hz\\%d.wav',i);
x=wavread(fname);
x=x(:,1);
[c,l]=wavedec(x,3,'db4');
ca=appcoef(c,l,'db4',3);%近似系数
x=ca;
enframex=enframe(x,128,64);%对信号x分帧处理,每帧有128个采样点,相邻帧之间有50%的叠加率
[row,col]=size(enframex);%返回行,列,每一行代表一帧,每一列表示1到128个采样点
A=abs(enframex).^2;
energy=zeros(row,1);
for j=1:row
energy(j)=sum(A(j,:));
end
for j=1:row
s(j)=0;
s(j)=s(j)+energy(j).*log10(energy(j));
end
Err=-s;music(i)=0;
for k=1:row
if Err(1,k) music(i)=music(i)+1;
end
end
musicshangbi(1,i)=music(i)/row;
end
musicshangbi