clear all
for i=1:30
fname=sprintf('D:\\study\\音频采样\\speechwithmusic\\%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=log10(abs(enframex).^2);
energy=zeros(row,1);
for j=1:row
energy(j)=sum(A(j,:));
end
s=0;
for j=1:row
s=s+energy(j);
end
s=0.7*(s/row);
swm(i)=0;
for k=1:row
if energy(k,1) swm(i)=swm(i)+1;
end
end
swmshangbi(i,1)=swm(i)/row;
end
swmshangbi
clear
for i=1:30
fname=sprintf('D:\\study\\音频采样\\speech\\%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=log10(abs(enframex).^2);
energy=zeros(row,1);
for j=1:row
energy(j)=sum(A(j,:));
end
s=0;
for j=1:row
s=s+energy(j);
end
s=0.7*(s/row);
speech(i)=0;
for k=1:row
if energy(k,1) speech(i)=speech(i)+1;
end
end
speechshangbi(i,1)=speech(i)/row;
end
speechshangbi
clear
for i=1:30
fname=sprintf('D:\\study\\音频采样\\music\\%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=log10(abs(enframex).^2);
energy=zeros(row,1);
for j=1:row
energy(j)=sum(A(j,:));
end
s=0;
for j=1:row
s=s+energy(j);
end
s=0.7*(s/row);
music(i)=0;
for k=1:row
if energy(k,1) music(i)=music(i)+1;
end
end
musicshangbi(i,1)=music(i)/row;
end
musicshangbi