资源描述:
《小波去噪matlab程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、[转帖]小波去噪matlab程序******************************************clearclc%在噪声环境下语音信号的增强%语音信号为读入的声音文件%噪声为正态随机噪声sound=wavread('c12345.wav');count1=length(sound);noise=0.05*randn(1,count1);fori=1:count1signal(i)=sound(i);endfori=1:count1y(i)=signal(i)+noise(i);end%在小波基'db3'下进行一维离散小波变换[coefs1,coefs
2、2]=dwt(y,'db3');%[低频高频]count2=length(coefs1);count3=length(coefs2);energy1=sum((abs(coefs1)).^2);energy2=sum((abs(coefs2)).^2);energy3=energy1+energy2;fori=1:count2recoefs1(i)=coefs1(i)/energy3;endfori=1:count3recoefs2(i)=coefs2(i)/energy3;end%低频系数进行语音信号清浊音的判别zhen=160;count4=fix(count2/z
3、hen);fori=1:count4n=160*(i-1)+1:160+160*(i-1);s=sound(n);w=hamming(160);sw=s.*w;a=aryule(sw,10);sw=filter(a,1,sw);sw=sw/sum(sw);r=xcorr(sw,'biased');corr=max(r);%为清音(unvoice)时,输出为1;为浊音(voice)时,输出为0ifcorr>=0.8output1(i)=0;elseifcorr<=0.1output1(i)=1;endendfori=1:count4n=160*(i-1)+1:160+16
4、0*(i-1);ifoutput1(i)==1switchabs(recoefs1(i))caseabs(recoefs1(i))<=0.002recoefs1(i)=0;caseabs(recoefs1(i))>0.002&abs(recoefs1(i))<=0.003recoefs1(i)=sgn(recoefs1(i))*(0.003*abs(recoefs1(i))-0.000003)/0.002;otherwiserecoefs1(i)=recoefs1(i);endelseifoutput1(i)==0recoefs1(i)=recoefs1(i);ende
5、nd%对高频系数进行语音信号清浊音的判别count5=fix(count3/zhen);fori=1:count5n=160*(i-1)+1:160+160*(i-1);s=sound(n);w=hamming(160);sw=s.*w;a=aryule(sw,10);sw=filter(a,1,sw);sw=sw/sum(sw);r=xcorr(sw,'biased');corr=max(r);%为清音(unvoice)时,输出为1;为浊音(voice)时,输出为0ifcorr>=0.8output2(i)=0;elseifcorr<=0.1output2(i)=1;
6、endendfori=1:count5n=160*(i-1)+1:160+160*(i-1);ifoutput2(i)==1switchabs(recoefs2(i))caseabs(recoefs2(i))<=0.002recoefs2(i)=0;caseabs(recoefs2(i))>0.002&abs(recoefs2(i))<=0.003recoefs2(i)=sgn(recoefs2(i))*(0.003*abs(recoefs2(i))-0.000003)/0.002;otherwiserecoefs2(i)=recoefs2(i);endelseifou
7、tput2(i)==0recoefs2(i)=recoefs2(i);endend%在小波基'db3'下进行一维离散小波反变换output3=idwt(recoefs1,recoefs2,'db3');%对输出信号抽样点值进行归一化处理maxdata=max(output3);output4=output3/maxdata;%读出带噪语音信号,存为'101.wav'wavwrite(y,5500,16,'c101');%读出处理后语音信号,存为'102.wav'wavwrite(output4,5500,16,'c102');