资源描述:
《小波变换语音消噪(改进阈值)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、改进阈值函数进行语音信号消噪,但是在程序运行过程中频频报错。本人经验不足调试不出,希望求得各位指导。改进函数表达式附图clearall;clc;closeall;fs=8000; %语音信号采样频率为8000xx=wavread('lw1.wav');x1=xx(:,1);%取单声道t=(0:length(x1)-1)/8000;y1=fft(x1,2048); %对信号做2048点FFT变换f=fs*(0:1023)/2048;figure(1)plot(t,x1)
2、 %做原始语音信号的时域图形y=awgn(x1',10,'measured'); %加10db的高斯白噪声[snr,mse]=snrmse(x1,y')%求得信噪比均方误差figure(2)plot(t,y) %做加噪语音信号的时域图形[c,l]=wavedec(y,3,'db1');%多尺度一维分解%用db1小波对信号进行3层分解并提取系数a3=appcoef(c,l,'db1',3);%a2=appcoef(c,l,'db1',2);%a1=appcoef(c,l,'db1',
3、1);d3=detcoef(c,l,3);d2=detcoef(c,l,2);d1=detcoef(c,l,1);thr1=thselect(d1,'rigrsure');%阈值获取,使用Stein的无偏风险估计原理thr2=thselect(d2,'rigrsure');thr3=thselect(d3,'rigrsure');%利用改进阈值函数进行去噪处理gd1=Garrote_gg(d1,thr1);gd2=Garrote_gg(d2,thr2);gd3=Garrote_gg(d3,thr3);c1=[a3g
4、d3gd2gd1];y1=waverec(c2,l,'db1');%多尺度重构[snr,mse]=snrmse(x1,y1')%求得信噪比均方误差figure(3);plot(t,y1);functiongd=Garrote_gg(a,b)%a为信号分解后的小波系数,b为获得的阈值m=0.2*((a*a)-(b*b));if(abs(a)>=b) gd=sign(a)*(abs(a)-b/exp(m));else(abs(a)
5、计算信噪比函数%I:原始信号%In:去噪后信号snr=0;Ps=sum(sum((I-mean(mean(I))).^2));%signalpowerPn=sum(sum((I-In).^2)); %noisepowersnr=10*log10(Ps/Pn);mse=Pn/length(I);QQ截图20130516175535.png (11.18KB,下载次数:0)改进函数表达式本帖最后由罗志雄于2013-5-1621:58编辑function[snr,mse]=snrmse(I,In)%计算信噪
6、比函数%I:原始信号%In:去噪后信号snr=0;Ps=sum(sum((I-mean(mean(I))).^2));%signalpowerPn=sum(sum((I-In).^2)); %noisepowersnr=10*log10(Ps/Pn);mse=Pn/length(I);修改后程序清单如下:clearall;clc;closeall;fs=8000; %语音信号采样频率为8000xx=wavread('lw1.wav');x1=xx(:,1);%取单声道x1=x1-
7、mean(x1);t=(0:length(x1)-1)/8000;y1=fft(x1,2048); %对信号做2048点FFT变换f=fs*(0:1023)/2048;figure(1)plot(t,x1) %做原始语音信号的时域图形y=awgn(x1',10,'measured'); %加10db的高斯白噪声[snr,mse]=snrmsel(x1',y) %求得信噪比均方误差snr1=SNR_singlech(x1',y)figure(2)plot(t,y)
8、 %做加噪语音信号的时域图形[c,l]=wavedec(y,3,'db1');%多尺度一维分解%用db1小波对信号进行3层分解并提取系数a3=appcoef(c,l,'db1',3);%a2=appcoef(c,l,'db1',2);%a1=appcoef(c,l,'db1',1);d3=detcoef(c,l,3);d2=detcoef(c,l