语音信号的数字滤波处理 下载本文

语音信号的数字滤波处理——巴特沃思、bartlett窗滤波器设计

subplot(2,1,1); plot(x);

%sound(x,FS,bits); %回放语音 title('语音信号时域波形图') y=fft(x,3260);

f=(FS/1630)*[1:1630]; subplot(2,1,2);

plot(f(1:1630),abs(y(1:1630))); title('语音信号频谱图'); %产生噪声信号并加到语音信号 t=0:length(x)-1;

zs=0.05*cos(2*pi*10000*t/22050); zs0=0.05*cos(2*pi*10000*t/22050000); figure(2); subplot(2,1,1) plot(zs0)

title('噪声信号波形'); zs1=fft(zs,1200);

%sound(zs,FS,bits); %回放噪音 subplot(2,1,2)

plot(f(1:600),abs(zs1(1:600))); title('噪声信号频谱'); x1=x+zs';

%sound(x1,FS,bits); %回放加入噪声后的语音 y1=fft(x1,1200); figure(3);

subplot(2,1,1);plot(x1); title('加入噪声后的信号波形'); subplot(2,1,2);

第 45 页 共 56 页

语音信号的数字滤波处理——巴特沃思、bartlett窗滤波器设计

plot(f(1:600),abs(y1(1:600))); title('加入噪声后的信号频谱'); %低通滤波

fp=3000;fs=3500;Fs=22050; rp=1;rs=10; wp=2*pi*fp/Fs; ws=2*pi*fs/Fs; Fs1=1;

wap=2*tan(wp/2); was=2*tan(ws/2);

[N,wc]=buttord(wap,was,rp,rs,'s'); [B,A]=butter(N,wc,'s'); [Bz,Az]=bilinear(B,A,Fs1); figure(4);

[h,w]=freqz(Bz,Az,512,Fs1*22050); plot(w,abs(h));

title('巴特沃斯低通滤波器');

xlabel('频率(HZ)');ylabel('耗损(dB)'); grid on;

yd=filter(Bz,Az,x1); figure(5);

subplot(2,1,1);plot(yd); title('滤波后信号波形'); ydd=fft(yd,1200);

subplot(2,1,2);plot(f(1:600),abs(ydd(1:600))); title('滤波后信号频谱'); sound(yd,FS,bits)

附录B巴特沃思高通滤波器仿真程序

Fs=22050;

[x,FS,bits]=wavread('D:\\ding.wav');

第 46 页 共 56 页

语音信号的数字滤波处理——巴特沃思、bartlett窗滤波器设计

x=x(:,1); figure(1); subplot(2,1,1); plot(x);

%sound(x,FS,bits); %回放语音 title('语音信号时域波形图') y=fft(x,3260);

f=(FS/1630)*[1:1630]; subplot(2,1,2);

plot(f(1:1630),abs(y(1:1630))); title('语音信号频谱图'); %产生噪声信号并加到语音信号 t=0:length(x)-1;

zs0=0.05*cos(2*pi*100*t/22050); figure(2); subplot(2,1,1) plot(zs0)

title('噪声信号波形'); zs1=fft(zs0,1200);

%sound(zs,FS,bits); %回放噪音 subplot(2,1,2)

plot(f(1:600),abs(zs1(1:600))); title('噪声信号频谱'); x1=x+zs0';

%sound(x1,FS,bits); %回放加入噪声后的语音 y1=fft(x1,1200); figure(3);

subplot(2,1,1);plot(x1); title('加入噪声后的信号波形');

第 47 页 共 56 页

语音信号的数字滤波处理——巴特沃思、bartlett窗滤波器设计

subplot(2,1,2);

plot(f(1:600),abs(y1(1:600))); title('加入噪声后的信号频谱'); %高通滤波

fp=600;fs=400;Fs=22050; rp=1;rs=10; wp=2*pi*fp/Fs; ws=2*pi*fs/Fs; T=1;Fs1=1; wap=2*tan(wp/2); was=2*tan(ws/2);

[N,wc]=buttord(wap,was,rp,rs,'s'); [B,A]=butter(N,wc,'high','s'); [Bz,Az]=bilinear(B,A,Fs1); figure(4);

[h,w]=freqz(Bz,Az,512,Fs1*22050); plot(w,abs(h));

title('巴特沃斯高通滤波器');

xlabel('频率(HZ)');ylabel('耗损(dB)'); grid on;

yd=filter(Bz,Az,x1); figure(5);

subplot(2,1,1);plot(yd); title('滤波后信号波形'); ydd=fft(yd,1200);

subplot(2,1,2);plot(f(1:600),abs(ydd(1:600))); title('滤波后信号频谱'); sound(yd,FS,bits)

附录C巴特沃思带通滤波器仿真程序

Fs=22050;

第 48 页 共 56 页