function varargout = bishe(varargin)
% BISHE MATLAB code for bishe.fig
% BISHE, by itself, creates a new BISHE or raises the existing
% singleton*.
% H = BISHE returns the handle to a new BISHE or the handle to
% the existing singleton*.
% BISHE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BISHE.M with the given input arguments.
% BISHE('Property','Value',...) creates a new BISHE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before bishe_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to bishe_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 bishe
% Last Modified by GUIDE v2.5 14-Apr-2013 11:52:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @bishe_OpeningFcn, ...
'gui_OutputFcn', @bishe_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
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 bishe is made visible.
function bishe_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 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);
% --- 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
% 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)
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\\%d2.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\\%d3.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
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);