% handles structure with handles and user data (see GUIDATA) % varargin command line arguments to bishe (see VARARGIN) % Choose default command line output for bishe handles.output = hObject; % Update handles structure guidata(hObject, handles);
% UIWAIT makes bishe wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = bishe_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 structure varargout{1} = handles.output;
% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles) % hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close;
% --- Executes on button press in luyin2.
function luyin2_Callback(hObject, eventdata, handles) % hObject handle to luyin2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global b; fs=16000; t=2;
b=wavrecord(t*fs,fs); handles.b=b;
guidata(hObject, handles);
% --- Executes on button press in zanting2.
function zanting2_Callback(hObject, eventdata, handles) % hObject handle to zanting2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global b;
pause(handles.b);
guidata(hObject, handles);
31
% --- Executes on button press in bofang2.
function bofang2_Callback(hObject, eventdata, handles) % hObject handle to bofang2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global b;
wavplay(b,22050); axes(handles.axes2); plot(b);
guidata(hObject, handles);
% --- Executes on button press in baocun2.
function baocun2_Callback(hObject, eventdata, handles) % hObject handle to baocun2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global b;
[filename pathname]=uiputfile({'*.wav','wav-files(*.wav)';'*.*','All-files(*.*)'},'另存为'); str=strcat(pathname,filename); save(str,'b');
wavwrite(b,16000,str); guidata(hObject, handles);
% --- Executes on button press in duqu2.
function duqu2_Callback(hObject, eventdata, handles) % hObject handle to duqu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global m2; global x1; global x2;
[fname,L]=uigetfile({'*.wav','All MATLAB Files(*.wav)';'*.*','All-files(*.*)'},''); file=[L,fname];
[S,fs]=wavread(file); figure
[x1,x2]=vad(S); axes(handles.axes2); m2=mfcc(S);
guidata(hObject, handles);
% --- Executes on button press in luyin1.
function luyin1_Callback(hObject, eventdata, handles) % hObject handle to luyin1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
32
% handles structure with handles and user data (see GUIDATA) global a; fs=16000; t=2;
a=wavrecord(t*fs,fs); handles.a=a;
guidata(hObject, handles);
% --- Executes on button press in zaiting1.
function zaiting1_Callback(hObject, eventdata, handles) % hObject handle to zaiting1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a;
pause(handles.a);
guidata(hObject, handles);
% --- Executes on button press in bofang1.
function bofang1_Callback(hObject, eventdata, handles) % hObject handle to bofang1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a;
wavplay(a,22050); axes(handles.axes1); plot(a);
guidata(hObject, handles);
% --- Executes on button press in baocun1.
function baocun1_Callback(hObject, eventdata, handles) % hObject handle to baocun1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global a;
[filename pathname]=uiputfile({'*.wav','wav-files(*.wav)';'*.*','All-files(*.*)'},'另存为'); str=strcat(pathname,filename); save(str,'a');
wavwrite(a,16000,str); guidata(hObject, handles);
% --- Executes on button press in duqu1.
function duqu1_Callback(hObject, eventdata, handles) % hObject handle to duqu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
33
global m1; global x1; global x2;
[fname,L]=uigetfile({'*.wav','All MATLAB Files(*.wav)';'*.*','All-files(*.*)'},'Pick a file','MultiSelect', 'on'); file=[L,fname];
[S,fs]=wavread(file); figure
subplot(2,1,1); plot(S);
[x1,x2]=vad(S); axes(handles.axes1); m1=mfcc(S);
guidata(hObject, handles);
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles) % hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global m1; global m2; global x1; global x2; for i=1:10
fname=sprintf('test1\\\\ò.wav',i-1); x=wavread(fname); [x1 x2]=vad1(x); axes(handles.axes1); m2=mfcc(x); m2=m2(x1:x2,:); test(i).mfcc=m2; end
for i=1:10
fname=sprintf('train1\\\\ó.wav',i-1); x=wavread(fname); [x1 x2]=vad1(x); axes(handles.axes2); m1=mfcc(x); m1=m1(x1:x2,:); ref(i).mfcc=m1; end
dist=zeros(10,10); for i=1:10 for j=1:10
34
dist(i,j)=dtw(test(i).mfcc,ref(j).mfcc); end end
for i=1:10
[d,j]=min(dist(i,:));
fprintf('测试模板%d的识别结果为:%d\\n',i-1,j-1); end
guidata(hObject, handles);
35
致 谢
大学四年一直以来,感谢华南农业大学对我的栽培;在本次设计中,感谢指导老师俞龙老师的关心和严格的指导,感谢论坛中网友的友好解答,也要感谢在这次毕业设计中同学们对我的帮助,没有他们,本次设计也没那么容易做出来;四年的学习生涯,感谢老师们对我的栽培;最后,感谢父母这么多年来对我的养育之恩!谢谢大家!
36