您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 基于matlab语音信号的处理的有关程序与GUI
[y,fs,bits]=wavread('E:\Englishofuniversity\12.wav');%(该语音文件放在E盘下)sound(y,fs,bits);%使用该语句播放原始语音信号Y=fft(y,4096);figure(1)subplot(211),plot(y);title('原始信号波形');subplot(212),plot(abs(Y));title('原始信号频谱');fp=1000;fc=1200;As=100;Ap=1;fs=44100;%滤波器参数wc=2*fc/fs;wp=2*fp/fs;%变换为数字域参数N=ceil((As-7.95)/(14.36*(wc-wp)/2))+1;%滤波器阶数beta=0.1102*(As-8.7);%凯赛窗参数betaWin=kaiser(N+1,beta);%生成窗函数b=fir1(N,wc,Win);%设计滤波器figure(2)freqz(b,1,512,fs);%画出频谱图x=fftfilt(b,y);%滤波X=fft(x,4096);%FFTsound(x,fs,bits);%回放语音信号figure(3)subplot(211),plot(x);title('凯赛窗设计的低通滤波器滤波后信号波形');subplot(212),plot(abs(X));title('凯赛窗设计的低通滤波器滤波后信号频谱');fp1=1200;fp2=3000;fc1=1000;fc2=3200;As=100;Ap=1;fs=22050;%滤波器参数wc1=2*fc1/fs;wp1=2*fp1/fs;wc2=2*fc2/fs;wp2=2*fp2/fs;width=min((wp1-wc1),(wc2-wp2));%转换为数字域参数N=ceil((As-7.95)/(14.36*width/2))+1;%滤波器阶数beta=0.1102*(As-8.7);%凯赛窗参数betaWin=kaiser(N+1,beta);%生成窗函数wc=[wc1wc2];b=fir1(N,wc,Win);figure(4)freqz(b,1,512,fs);%画出滤波器频谱图(上图所示)x=fftfilt(b,y);%滤波X=fft(x,4096);%FFTsound(x,fs,bits);%回放语音信号figure(5)subplot(211),plot(x);title('凯赛窗设计的带通滤波器滤波后信号波形');subplot(212),plot(abs(X));title('凯赛窗设计的带通滤波器滤波后信号频谱');fp=5000;fc=4800;As=100;Ap=1;fs=22050;%高通滤波器参数wc=2*fc/fs;wp=2*fp/fs;N=ceil((As-7.95)/(14.36*(wp-wc)/2))+1;%滤波器阶数beta=0.1102*(As-8.7);%凯赛窗参数betaWin=kaiser(N+1,beta);%生成窗函数100b=fir1(N,wc,'high',Win);%设计高通滤波器-100200figure(6)freqz(b,1,512,fs);%-画出频谱图如右图所示x=fftfilt(b,y);%滤波X=fft(x,4096);%FFTsound(x,fs,bits);%回放语音信号figure(7)subplot(211),plot(x);title('凯赛窗设计的高通滤波器滤波后信号波形');subplot(212),plot(abs(X));title('凯赛窗设计的高通滤波器滤波后信号频谱');fp=1000;fc=1200;As=100;Ap=1;ffs=44100;wc=2*fc/ffs;wp=2*fp/ffs;[n,wn]=ellipord(wp,wc,Ap,As);%求阶数N和通带截止频率[num,den]=ellip(n,Ap,As,wn);%设计椭圆滤波器figure(8)freqz(num,den,256,ffs);%画出频率响应x=filter(num,den,y);%滤波X=fft(x,4096);%FFTfigure(9)subplot(211),plot(x);title('双线性变换法设计的低通滤波器滤波后信号波形');subplot(212),plot(abs(X));title('双线性变换法设计的低通滤波器滤波后信号频谱');fp=[3000,8000];fc=[1000,10000];Ap=1;As=100;ffs=44100wc=2*fc/ffs;wp=2*fp/ffs;[n,wn]=ellipord(wp,wc,Ap,As);[num,den]=ellip(n,Ap,As,wn);figure(10)freqz(num,den,256,ffs);x=filter(num,den,y);%滤波X=fft(x,4096);%FFTfigure(11)subplot(211),plot(x);title('双线性变换法设计的带通滤波器滤波后信号波形');subplot(212),plot(abs(X));title('双线性变换法设计的带通滤波器滤波后信号频谱');fp=5000;fc=4800;As=100;Ap=1;ffs=44100;wc=2*fc/ffs;wp=2*fp/ffs;[n,wn]=ellipord(wp,wc,Ap,As);[num,den]=ellip(n,Ap,As,wn,'high');x=filter(num,den,y);X=fft(x,4096);figure(12)freqz(num,den,256,ffs);figure(13)subplot(211),plot(x);title('双线性变换法设计的高通通滤波器滤波后信号波形');subplot(212),plot(abs(X));title('双线性变换法设计的高通通滤波器滤波后信号频谱');请将以上部分加入到记事本内并改为m文件GUIGUI.fig此文件放到桌面与下面的GUI.m文件一起用程序如下(如上所述改为GUI.m文件):functionvarargout=GUI(varargin)%GUIMATLABcodeforGUI.fig%GUI,byitself,createsanewGUIorraisestheexisting%singleton*.%%H=GUIreturnsthehandletoanewGUIorthehandleto%theexistingsingleton*.%%GUI('CALLBACK',hObject,eventData,handles,...)callsthelocal%functionnamedCALLBACKinGUI.Mwiththegiveninputarguments.%%GUI('Property','Value',...)createsanewGUIorraisesthe%existingsingleton*.Startingfromtheleft,propertyvaluepairsare%appliedtotheGUIbeforeGUI_OpeningFcngetscalled.An%unrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.AllinputsarepassedtoGUI_OpeningFcnviavarargin.%%*SeeGUIOptionsonGUIDE'sToolsmenu.ChooseGUIallowsonlyone%instancetorun(singleton).%%Seealso:GUIDE,GUIDATA,GUIHANDLES%EdittheabovetexttomodifytheresponsetohelpGUI%LastModifiedbyGUIDEv2.502-Jan-201422:57:31%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@GUI_OpeningFcn,...'gui_OutputFcn',@GUI_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%---ExecutesjustbeforeGUIismadevisible.functionGUI_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%varargincommandlineargumentstoGUI(seeVARARGIN)%ChoosedefaultcommandlineoutputforGUIhandles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesGUIwaitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);%---Outputsfromthisfunctionarereturnedtothecommandline.functionvarargout=GUI_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%---Executesonbuttonpressinpushbutton5.functionpushbutton5_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)functionedit1_Callback(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserv
本文标题:基于matlab语音信号的处理的有关程序与GUI
链接地址:https://www.777doc.com/doc-5426953 .html