基于MATLAB-GUI语音信号的采集分析系统_第1页
基于MATLAB-GUI语音信号的采集分析系统_第2页
基于MATLAB-GUI语音信号的采集分析系统_第3页
基于MATLAB-GUI语音信号的采集分析系统_第4页
基于MATLAB-GUI语音信号的采集分析系统_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

精品文档 1欢迎下载 基于 的语音信号采集分析系统 前一阵子用 MATLAB GUI 做了一个语音信号采集与分析的界面 功能包括录音 播放 时 域 频域分析吧 也导入本地文件进行分析 效果如下 源码如下 function varargout GUI 1 varargin GUI 1 MATLAB code for GUI 1 fig GUI 1 by itself creates a new GUI 1 or raises the existing singleton H GUI 1 returns the handle to a new GUI 1 or the handle to the existing singleton GUI 1 CALLBACK hObject eventData handles calls the local function named CALLBACK in GUI 1 M with the given input arguments GUI 1 Property Value creates a new GUI 1 or raises the existing singleton Starting from the left property value pairs are applied to the GUI before GUI 1 OpeningFcn gets called An unrecognized property name or invalid value makes property application stop All inputs are passed to GUI 1 OpeningFcn via varargin See GUI Options on GUIDE s Tools menu Choose GUI allows only one instance to run singleton See also GUIDE GUIDATA GUIHANDLES Edit the above text to modify the response to help GUI 1 精品文档 2欢迎下载 Last Modified by GUIDE v2 5 25 May 2015 20 52 27 Begin initialization code DO NOT EDIT gui Singleton 1 gui State struct gui Name mfilename gui Singleton gui Singleton gui OpeningFcn GUI 1 OpeningFcn gui OutputFcn GUI 1 OutputFcn gui LayoutFcn gui Callback if nargin end if nargout varargout 1 nargout gui mainfcn gui State varargin else gui mainfcn gui State varargin end End initialization code DO NOT EDIT Executes just before GUI 1 is made visible function GUI 1 OpeningFcn hObject handles varargin This function has no output args see OutputFcn hObject handle to figure eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA varargin command line arguments to GUI 1 see VARARGIN Choose default command line output for GUI 1 set handles axes t m visible off set handles axes fft m visible off set handles axes t w visible off set handles axes fft w visible off global local yn local yn 0 a imread yanda jpg axes handles axes t m image a handles output hObject Update handles structure guidata hObject handles 精品文档 3欢迎下载 UIWAIT makes GUI 1 wait for user response see UIRESUME uiwait handles figure1 ha axes units normalized position 0 0 1 1 uistack ha down II imread 暖色 JPG image II colormap gray set ha handlevisibility off visible off Outputs from this function are returned to the command line function varargout GUI 1 OutputFcn handles varargout cell array for returning output args see VARARGOUT hObject handle to figure eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Get default command line output from handles structure varargout 1 handles output Executes on button press in pushbutton luyin function pushbutton luyin Callback hObject handles hObject handle to pushbutton luyin see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global recObj keyboard global sex flag switch sex flag case 0 set handles axes t m visible on set handles axes fft m visible on set handles axes t w visible off set handles axes fft w visible off case 1 set handles axes t m visible off set handles axes fft m visible off set handles axes t w visible off set handles axes fft w visible off case 2 set handles axes t m visible off set handles axes fft m visible off set handles axes t w visible off set handles axes fft w visible off 精品文档 4欢迎下载 end global local yn local yn 0 fs chose handles fs chose nBits 8 nChannels 1 canshu fs chose nBits nChannels if str2double get handles et time String 0 添加 str2double 后正常 set handles set time String 时间参数输入错误 msgbox 认真点好吗亲 输入时间参数先 错误提示 Icon set handles set time BackgroundColor red pause 1 set handles set time BackgroundColor default set handles set time String 请输入录音时长 else cla handles axes t m reset set handles axes t m visible off set handles pushbutton luyin BackgroundColor green set handles pushbutton luyin String 正在录音 recObj audiorecorder fs chose nBits nChannels disp Start speaking recordblocking recObj handles recor time disp End of Recording set handles pushbutton luyin BackgroundColor yellow set handles pushbutton luyin String 录音结束 play recObj pause 1 新加代码 加入语音识别 刘帅 20150526 myRecording getaudiodata recObj y1 myRecording L length y1 NFFT 2 nextpow2 L Next power of 2 from length of y Y fft y1 NFFT L f fs chose 2 linspace 0 1 NFFT 2 1 keyboard a 0 for i 1 fs chose 2 if 2 abs Y 0 00015 if 2 abs Y 1e 5 if i 2 msgbox 你个 性别提示 Icon a a 1 end 精品文档 5欢迎下载 end if a 10 msgbox 你个 性别提示 Icon end keyboard axes handles axes fft m plot f 2 abs Y 1 NFFT 2 1 语音识别刘帅 20150526 set handles pushbutton luyin BackgroundColor red set handles pushbutton luyin String 点我录音 handles recObj recObj guidata hObject handles 更新 handles 里的数据 end 回放录音数据 play recObj 获取录音数据 myRecording getaudiodata recObj 绘制录音数据波形 plot myRecording keyboard Executes on button press in pushbutton plot function pushbutton plot Callback hObject handles hObject handle to pushbutton plot see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA 回放录音数据 set handles axes t m visible on set handles axes fft m visible on global local yn global sex flag switch local yn case 0 if str2double get handles et time String 0 添加 str2double 后正常 msgbox 亲 别逗好吗 请录音或者选择本地文件先 Error Icon errordlg 亲 别逗好吗 请输入时间参数或者选择本地文件先 Error on else switch sex flag case 0 recObj handles recObj 获取录音数据 精品文档 6欢迎下载 myRecording getaudiodata recObj uint8 myRecording getaudiodata recObj d myRecording name get handles et savme String audiowrite name d 8000 audiowrite name d handles fs chose msgbox 数据保存成功 消息提示 Icon 绘制录音数据波形 axes handles axes t m draw m plot myRecording title 时域信号 xlabel t ylabel 幅值 Fs 16000 fs handles fs chose 采集频率 y1 myRecording 一维矩阵 L length y1 计算元素个数 NFFT 2 nextpow2 L Next power of 2 from length of y 提高 运算速度 Y fft y1 NFFT L 傅里叶变换 NFFT 级蝶形运算 f fs 2 linspace 0 1 NFFT 2 1 x 轴点数 Plot single sided amplitude spectrum axes handles axes fft m draw fft m plot f 2 abs Y 1 NFFT 2 1 title 频域信号 xlabel Frequency Hz ylabel Y f xFFT fft data xfft abs xFFT Avoid taking the log of 0 index xfft 0 xfft index 1e 17 mag 20 log10 xfft mag mag 1 blockSize 2 f 0 length mag 1 Fs blockSize f f axes handles axes fft m draw fft m plot f 1 mag 1 ylabel Magnitude dB 精品文档 7欢迎下载 xlabel Frequency Hz title 频谱图 Fs 1000 nbit 24 wavwrite myRecording 1000 24 test 1 wav MATLAB 写 wav 文件 看最大最小值 myRecording fft Fs nbits wavread test 1 wav MATLAB 读 wav 文件 看最大最小值 预计是在 1 和 1 之间 N length myRecording fft Fm fft myRecording fft N axes handles axes fft m draw fft m plot handles axes fft m 100 abs Fm title 频域信号 xlabel w ylabel 幅值 handles draw fft m draw fft m guidata hObject handles handles draw plot m draw m guidata hObject handles case 1 recObj handles recObj 获取录音数据 myRecording getaudiodata recObj 绘制录音数据波形 axes handles axes t w draw w plot handles axes t w myRecording m ylabel Amplitude xlabel Time title 时域信号 fs handles fs chose y1 myRecording L length y1 NFFT 2 nextpow2 L Next power of 2 from length of y Y fft y1 NFFT L f fs 2 linspace 0 1 NFFT 2 1 Plot single sided amplitude spectrum axes handles axes fft w draw fft w plot f 2 abs Y 1 NFFT 2 1 m title 频域信号 xlabel Frequency Hz ylabel Y f xFFT fft data 精品文档 8欢迎下载 xfft abs xFFT Avoid taking the log of 0 index xfft 0 xfft index 1e 17 mag 20 log10 xfft mag mag 1 blockSize 2 f 0 length mag 1 Fs blockSize f f axes handles axes fft w draw fft w plot f 1 mag 1 ylabel Magnitude dB xlabel Frequency Hz title 频谱图 Fw fft myRecording 4096 axes handles axes fft w draw fft w plot handles axes fft w abs Fw title 频域信号 xlabel w ylabel 幅值 handles draw fft w draw fft w guidata hObject handles handles draw plot w draw w guidata hObject handles case 2 msgbox 妖孽 哪里逃 haha Icon end end case 1 FileName handles FileName y1 fs audioread FileName axes handles axes t m draw fft m plot y1 ylabel Amplitude xlabel Time title 时域信号 L length y1 set gca ylim 0 2 myRecording getaudiodata aa uint8 NFFT 2 nextpow2 L Next power of 2 from length of y Y fft y1 NFFT L f fs 2 linspace 0 1 NFFT 2 1 精品文档 9欢迎下载 Plot single sided amplitude spectrum axes handles axes fft m draw fft m plot f 2 abs Y 1 NFFT 2 1 title 频域信号 xlabel Frequency Hz ylabel Y f Fs 16000 data myRecording blockSize length data xFFT fft data xfft abs xFFT Avoid taking the log of 0 index xfft 0 xfft index 1e 17 mag 20 log10 xfft mag mag 1 blockSize 2 f 0 length mag 1 Fs blockSize f f axes handles axes fft m draw fft m plot f 1 mag 1 ylabel Magnitude dB xlabel Frequency Hz title 频谱图 end Executes on button press in pushbutton play function pushbutton play Callback hObject handles hObject handle to pushbutton play see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global local yn keyboard switch local yn case 0 if str2double get handles et time String 0 添加 str2double 后正常 msgbox 亲 别逗好吗 请录音或者选择本地文件先 Error Icon errordlg 亲 别逗好吗 请输入时间参数或者选择本地文件先 Error on else recObj play handles recObj play recObj play set hObject BackgroundColor green set hObject String 正在播放 pause handles recor time 精品文档 10欢迎下载 set hObject BackgroundColor yellow set hObject String 播放完毕 pause 1 set hObject String 点我播放 guidata hObject handles end case 1 y fs audioread handles FileName sound y fs end function et time Callback hObject handles hObject handle to et time see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hints get hObject String returns contents of et time as text str2double get hObject String returns contents of et time as a double if isempty get hObject String set hObject String 0 set handles set time String 时间参数输入错误 pause 2 set handles set time String 请输入录音时长 guidata hObject handles else input str2double get hObject String handles recor time input guidata hObject handles end Executes during object creation after setting all properties function et time CreateFcn hObject hObject handle to et time see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc end Executes during object creation after setting all properties 精品文档 11欢迎下载 function axes t m CreateFcn hObject eventdata handles hObject handle to axes t m see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint place code in OpeningFcn to populate axes t m Executes on button press in rb man function rb man Callback hObject eventdata handles hObject handle to rb man see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hint get hObject Value returns toggle state of rb man Executes on button press in rb women function rb women Callback hObject eventdata handles hObject handle to rb women see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hint get hObject Value returns toggle state of rb women Executes on button press in rb Neither function rb Neither Callback hObject eventdata handles hObject handle to rb Neither see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hint get hObject Value returns toggle state of rb Neither Executes when selected object is changed in uipanel5 function uipanel5 SelectionChangeFcn hObject hObject handle to the selected object in uipanel5 eventdata structure with the following fields see UIBUTTONGROUP EventName string SelectionChanged read only OldValue handle of the previously selected object or empty if none was 精品文档 12欢迎下载 selected NewValue handle of the currently selected object handles structure with handles and user data see GUIDATA global sex flag switch get hObject Tag case rb man sex flag 0 case rb women sex flag 1 case rb Neither sex flag 2 end function menu intro Callback hObject eventdata handles hObject handle to menu intro see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA msg 1 V1 实现基本功能 录音 播放 画时域图 基本频谱图等 2 V2 改进算 法 重新改变频域信号处理函数 20150522 3 V2 5 加入 start 界面 尝试将讲解内容以图片形式导进 20150524 4 V2 6 加入采集频率可选下拉框 20150525 msgbox msg 版本说明 Executes during object creation after setting all properties function axes fft m CreateFcn hObject eventdata handles hObject handle to axes fft m see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint place code in OpeningFcn to populate axes fft m Executes on button press in pushbutton exit function pushbutton exit Callback hObject eventdata handles hObject handle to pushbutton exit see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA quest 亲 你真的要离开人家吗 response questdlg quest wennine Yeah Oh No 2 if strcmp response Yeah close 精品文档 13欢迎下载 start voice else end if response Yeah close else end function et savme Callback hObject eventdata handles hObject handle to et savme see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hints get hObject String returns contents of et savme as text str2double get hObject String returns contents of et savme as a double filename get hObject String handles filename filename guidata hObject handles Executes during object creation after setting all properties function et savme CreateFcn hObject eventdata handles hObject handle to et savme see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc end function et local Callback hObject eventdata handles hObject handle to et local see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Hints get hObject String returns contents of et local as text str2double get hObject String returns contents of et local as a double 精品文档 14欢迎下载 Executes during object creation after setting all properties function et local CreateFcn hObject eventdata handles hObject handle to et local see GCBO eventdata reserved to be defined in a future version of MATLAB handles empty handles not created until after all CreateFcns called Hint edit controls usually have a white background on Windows See ISPC and COMPUTER if ispc end Executes on button press in pushbutton local function pushbutton local Callback hObject eventdata handles hObject handle to pushbutton local see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global local yn local yn 1 FileName PathName uigetfile wav 亲 请选择您想要查看的音频文件 handles FileName FileName guidata hObject handles set handles et local String FileName data audioread FileName axes handles axes t m draw fft m plot data ylabel Amplitude xlabel Time title 时域图 set gca ylim 0 2 myRecording getaudiodata aa uint8 Fs 16000 data myRecording blockSize length data xFFT fft data xfft abs xFFT Avoid taking the log of 0 index xfft 0 xfft index 1e 17 mag 20 log10 xfft mag mag 1 blockSize 2 精品文档 15欢迎下载 f 0 length mag 1 Fs blockSize f f axes handles axes fft m draw fft m plot f 1 mag 1 ylabel Magnitude dB xlabel Frequency Hz title 频谱图 Executes during object creation a

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论