失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 【语音处理】基于matlab GUI语音时域频域频谱图分析【含Matlab源码 527期】

【语音处理】基于matlab GUI语音时域频域频谱图分析【含Matlab源码 527期】

时间:2018-08-06 07:03:25

相关推荐

【语音处理】基于matlab GUI语音时域频域频谱图分析【含Matlab源码 527期】

一、语音处理简介

MATLAB GUI是用户与计算机或计算机程序的接触点或交互方式,是用户与计算机进行信息交流的方式。图形用户界面(Graphical User Interfaces,GUI)则是由窗口、光标、按键、菜单、文字说明等对象(Object)构成的一个用户界面。用户通过一定的方法(如鼠标或键盘)选择、激活这些图形对象,使计算机产生某种动作或变化,比如实现计算、绘图等。本设计基于MATLAB GUI技术,完成了语音信号处理的界面平台,可进行语音的选取、线性预测分析(LPC)、语谱图、频谱等相关波形的显示。这样可以更直观、更方便地分析和处理语音信号,得到用户需要的实验结果。

具体理论知识参考:基于MATLAB GUI的语音处理界面设计

二、部分源代码

function varargout = gui(varargin)% GUI MATLAB code for gui.fig%GUI, by itself, creates a new GUI or raises the existing%singleton*.%%H = GUI returns the handle to a new GUI or the handle to%the existing singleton*.%%GUI('CALLBACK',hObject,eventData,handles,...) calls the local%function named CALLBACK in GUI.M with the given input arguments.%%GUI('Property','Value',...) creates a new GUI or raises the%existing singleton*. Starting from the left, property value pairs are%applied to the GUI before gui_OpeningFcn gets called. An%unrecognized property name or invalid value makes property application%stop. All inputs are passed to gui_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% Last Modified by GUIDE v2.5 23-Apr- 15:32:28% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @gui_OpeningFcn, ...'gui_OutputFcn', @gui_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before gui is made visible.function gui_OpeningFcn(hObject, eventdata, 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 (see VARARGIN)% Choose default command line output for guihandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_OutputFcn(hObject, eventdata, 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 structurevarargout{1} = handles.output;% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBitsglobal mag idx_last recObj myRecording bitrecord(recObj,RecordLength);ticwhile toc<.1endbit = 2;while toc<RecordLengthmyRecording = getaudiodata(recObj);idx = round(toc*fs);while idx-idx_last<.1*fsidx=round(toc*fs);endaxes(handles.axes1)plot((max(1,size(myRecording,1)-fs*ShowLength):(2^bit):size(myRecording,1))./fs,myRecording(max(1,size(myRecording,1)-fs*ShowLength):(2^bit):end))mag = max(abs(myRecording));ylim([-1.2 1.2]*mag)xlim([max(0,size(myRecording,1)/fs-ShowLength)max(size(myRecording,1)/fs,ShowLength)])title('声音信号的波形显示');ylabel('Signal level(volts)');xlabel('Samples');drawnowidx_last = idx;end% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBitsglobal mag idx_last recObj myRecordingsave data.mat aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBits mag idx_last recObj myRecording % --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)clc,clear,close all force;% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBitsglobal mag idx_last recObjaud = audiodevinfo;RecordLength = 15;ShowLength = 15;FrequencyWindow1 = 0;FrequencyWindow2 = 3000;fs = 44100;nBits = 16;mag = 1.05;idx_last = 1;recObj = audiorecorder(fs,nBits,1);if isempty(recObj);elsemsgbox('语音设备已检测到!!!');end% --- Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton7.function pushbutton7_Callback(hObject, eventdata, handles)% hObject handle to pushbutton7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global fsload('data.mat')sound(myRecording,fs);% --------------------------------------------------------------------function Untitled_1_Callback(hObject, eventdata, handles)% hObject handle to Untitled_1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBitsglobal mag idx_last recObj myRecording bit x3x1 = myRecording(max(1,size(myRecording,1)-fs*ShowLength):(2^bit):end);N=length(x1);x2 = x1-mean(x1);x3 = smooth(x2);axes(handles.axes1)plot(x3,'b-','linewidth',2)axis tighttitle('零均值化——平滑滤波')% --------------------------------------------------------------------function Untitled_2_Callback(hObject, eventdata, handles)% hObject handle to Untitled_2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

三、运行结果

四、matlab版本及参考文献

1 matlab版本

a

2 参考文献

[1]韩纪庆,张磊,郑铁然.语音信号处理(第3版)[M].清华大学出版社,.

[2]柳若边.深度学习:语音识别技术实践[M].清华大学出版社,.

[3]宋云飞,姜占才,魏中华.基于MATLAB GUI的语音处理界面设计[J].科技信息. ,(02)

如果觉得《【语音处理】基于matlab GUI语音时域频域频谱图分析【含Matlab源码 527期】》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。