clc
syms x1 x2 ;
f=x1^2+4x2^2;
fx1=diff(f,'x1'); fx2=diff(f,'x2');
fx1x1=diff(fx1,'x1');fx1x2=diff(fx1,'x2');fx2x1=diff(fx2,'x1');fx2x2=diff(fx2,'x2');
x1=2;
x2=2;
for n=1:100
f0=subs(f);
f1=subs(fx1);
f2=subs(fx2);
if (double(sqrt(f1^2+f2^2)) <= 0002)
n;
x1=vpa(x1,4);
x2=vpa(x2,4);
f0=vpa(f0,4);
break;
else
X=[x1 x2]'-inv([fx1x1 fx1x2;fx2x1 fx2x2])[f1 f2]';
x1=X(1,1);
x2=X(2,1);
end
end
%语音信号为读入的声音文件
%噪声为正态随机噪声
sound=wavread('c12345wav');
count1=length(sound);
noise=005randn(1,count1);
for i=1:count1
signal(i)=sound(i);
end
for i=1:count1
y(i)=signal(i)+noise(i);
end
%在小波基'db3'下进行一维离散小波变换
[coefs1,coefs2]=dwt(y,'db3'); %[低频 高频]
count2=length(coefs1);
count3=length(coefs2);
energy1=sum((abs(coefs1))^2);
energy2=sum((abs(coefs2))^2);
energy3=energy1+energy2;
for i=1:count2
recoefs1(i)=coefs1(i)/energy3;
end
for i=1:count3
recoefs2(i)=coefs2(i)/energy3;
end
%低频系数进行语音信号清浊音的判别
zhen=160;
count4=fix(count2/zhen);
for i=1:count4
n=160(i-1)+1:160+160(i-1);
s=sound(n);
w=hamming(160);
sw=sw;
a=aryule(sw,10);
sw=filter(a,1,sw);
sw=sw/sum(sw);
r=xcorr(sw,'biased');
corr=max(r);
%为清音(unvoice)时,输出为1;为浊音(voice)时,输出为0
if corr>=08
output1(i)=0;
elseif corr<=01
output1(i)=1;
end
end
for i=1:count4
n=160(i-1)+1:160+160(i-1);
if output1(i)==1
switch abs(recoefs1(i))
case abs(recoefs1(i))<=0002
recoefs1(i)=0;
case abs(recoefs1(i))>0002 & abs(recoefs1(i))<=0003
recoefs1(i)=sgn(recoefs1(i))(0003abs(recoefs1(i))-0000003)/0002;
otherwise recoefs1(i)=recoefs1(i);
end
elseif output1(i)==0
recoefs1(i)=recoefs1(i);
end
end
%对高频系数进行语音信号清浊音的判别
count5=fix(count3/zhen);
for i=1:count5
n=160(i-1)+1:160+160(i-1);
s=sound(n);
w=hamming(160);
sw=sw;
a=aryule(sw,10);
sw=filter(a,1,sw);
sw=sw/sum(sw);
r=xcorr(sw,'biased');
corr=max(r);
%为清音(unvoice)时,输出为1;为浊音(voice)时,输出为0
if corr>=08
output2(i)=0;
elseif corr<=01
output2(i)=1;
end
end
for i=1:count5
n=160(i-1)+1:160+160(i-1);
if output2(i)==1
switch abs(recoefs2(i))
case abs(recoefs2(i))<=0002
recoefs2(i)=0;
case abs(recoefs2(i))>0002 & abs(recoefs2(i))<=0003
recoefs2(i)=sgn(recoefs2(i))(0003abs(recoefs2(i))-0000003)/0002;
otherwise recoefs2(i)=recoefs2(i);
end
elseif output2(i)==0
recoefs2(i)=recoefs2(i);
end
end
%在小波基'db3'下进行一维离散小波反变换
output3=idwt(recoefs1, recoefs2,'db3');
%对输出信号抽样点值进行归一化处理
maxdata=max(output3);
output4=output3/maxdata;
%读出带噪语音信号,存为'101wav'
wavwrite(y,5500,16,'c101');
%读出处理后语音信号,存为'102wav'
wavwrite(output4,5500,16,'c102');
以上就是关于关于Matlab的程序全部的内容,包括:关于Matlab的程序、谁有关于语音增强的MATLAB的程序、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)