Matlab:语音信号处理与滤波

您所在的位置:网站首页 matlab带通滤波器函数 Matlab:语音信号处理与滤波

Matlab:语音信号处理与滤波

2024-07-10 05:08| 来源: 网络整理| 查看: 265

文章目录 语音信号的采集对语音信号进行频谱分析设计数字滤波器利用滤波器进行滤波

注:本文章仅供参考,本人并非通信专业,相关知识早已忘得差不多了,所以不要再问我相关问题啦~sorry

语音信号的采集

首先利用win自带的录音机(没有的话手机录也行),录下一段语音信号,时间40秒左右。运用MATLAB对语音进行采样

[x,fs]=audioread('D:\1234.mp3'); plot(x);

出现如下的图 语音信号

对语音信号进行频谱分析

处理语音信号的时域波形图 对语音信号进行快速傅立叶变换,得到信号的频谱

clear [x,fs]=audioread('D:\1234.mp3'); x=x(:,1); FS=length(x); X=fft(x); t=(0:FS-1)/fs; figure(1) subplot(2,1,1);plot(t,x); title('原始语音信号时域波形'); xlabel('时间'); ylabel('赋值'); grid on; subplot(2,1,2);plot(abs(X)); title('原始语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 8]); grid on;

频谱

设计数字滤波器

可以运用窗函数法、双线性变换法设计低通、高通、带通三种滤波器。本次选用双线性变换法进行设计

(1) 利用ellipord函数设计IIR低通滤波器

Fp=1500; Fs=1200; Ft=8000; As=100; Ap=1; wp=2*pi*Fp/Ft; ws=2*pi*Fs/Ft; [n,wn]=ellipord(wp,ws,Ap,As,'s'); [b,a]=ellip(n,Ap,As,wn,'s'); [B,A]=bilinear(b,a,1); [h,w]=freqz(B,A); figure(2); plot(w*Ft/pi/2,abs(h)); title('IIR低通滤波器'); xlabel('频率'); ylabel('幅度'); grid on;

低通滤波器 (2) 利用ellipord函数设计IIR高通滤波器

Fp=1200; Fs=2200; Ft=8000; As=100; Ap=1; wp=2*pi*Fp/Ft; ws=2*pi*Fs/Ft; [n,wn]=ellipord(wp,ws,Ap,As,'s'); [b,a]=ellip(n,Ap,As,wn,'high','s'); [B,A]=bilinear(b,a,1); [h,w]=freqz(B,A); figure(4); plot(w*Ft/pi/2,abs(h)); title('IIR高通滤波器'); xlabel('频率'); ylabel('幅度'); grid on;

高通滤波器

(3) 利用ellipord函数设计IIR带通滤波器

Fp1=1200; Fp2=3000; Fs1=1000; Fs2=3200; Ft=8000; As=100; Ap=1; wp=[2*pi*Fp1/Ft,2*pi*Fp2/Ft]; ws=[2*pi*Fs1/Ft,2*pi*Fs2/Ft]; [n,wn]=ellipord(wp,ws,Ap,As,'s'); [b,a]=ellip(n,Ap,As,wn,'s'); [B,A]=bilinear(b,a,1); [h,w]=freqz(B,A); figure(6); plot(w*Ft/pi/2,abs(h)); title('IIR带通滤波器'); xlabel('频率'); ylabel('幅度'); grid on;

带通滤波器

利用滤波器进行滤波

(1)IIR低通滤波器

[x,fs]=audioread('D:\1234.mp3'); x=x(:,1); Y=fft(x); y=filter(B,A,x); Y1=fft(y); n=0:length(x)-1; t=(0:FS-1)/fs; figure(7); subplot(3,1,1);plot(t,y);grid on; title('IIR低通滤波器滤波后语音信号时域波形'); xlabel('时间'); ylabel('赋值'); subplot(3,1,2);plot(n,abs(Y));grid on; title('滤波前语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 8]); subplot(3,1,3);plot(n,abs(Y1));grid on; title('滤波后语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 8]);

在这里插入图片描述

(2)IIR高通滤波器

[x,fs]=audioread('D:\1234.mp3'); x=x(:,1); Y=fft(x); y=filter(B,A,x); Y1=fft(y); n=0:length(x)-1; t=(0:FS-1)/fs; figure(7); subplot(3,1,1);plot(t,y);grid on; title('IIR高通滤波器滤波后语音信号时域波形'); xlabel('时间'); ylabel('赋值'); subplot(3,1,2);plot(n,abs(Y));grid on; title('滤波前语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 8]); subplot(3,1,3);plot(n,abs(Y1));grid on; title('滤波后语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 8]);

在这里插入图片描述 (3) IIR带通滤波器

[x,fs]=audioread('D:\1234.mp3'); x=x(:,1); Y=fft(x); y=filter(B,A,x); Y1=fft(y); n=0:length(x)-1; t=(0:FS-1)/fs; figure(7); subplot(3,1,1);plot(t,y);grid on; title('IIR带通滤波器滤波后语音信号时域波形'); xlabel('时间'); ylabel('赋值'); subplot(3,1,2);plot(n,abs(Y));grid on; title('滤波前语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 5]); subplot(3,1,3);plot(n,abs(Y1));grid on; title('滤波后语音信号频谱'); xlabel('频率'); ylabel('幅度'); axis([0 1000000 0 5]);

在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3