function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 23-Apr-2018 16:20:43
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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 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)
%clc
%clear variables
%close
global file
global Group2
Tw = 25; % analysis frame duration (ms)
Ts = 10; % analysis frame shift (ms)
alpha = 0.97; % preemphasis coefficient
R = [ 300 3700 ]; % frequency range to consider
M = 20; % number of filterbank channels
C = 13; % number of cepstral coefficients
L = 22; % cepstral sine lifter parameter
fs = 16000;
% hamming window (see Eq. (5.2) on p.73 of [1])
hamming = @(N)(0.54-0.46*cos(2*pi*[0:N-1].'/(N-1)));
% Read speech samples, sampling rate and precision from file
N=10;
path = 'Validation_test_set';
file = dir(path);
file(1:2) = [];
speech=zeros(N*16000,16);
speech2=zeros(N*16000,16);
samples = [1,N*16000];
N_P=14;
for i = 1:length(file)
str=strcat('Validation_test_set','\',file(i).name);
speech(:,i) = audioread(str,samples);
speech2(:,i) = audioread(str,(samples+[N_P*16000,N_P*16000]));
end
MFCCS=zeros(10000,16);
MFCCS2=zeros(10000,16);
% Feature extraction (feature vectors as columns)
for i2 = 1:length(file)
[ mfccs, FBEs, frames ] = ...
mfcc( speech(:,i2), fs, Tw, Ts, alpha, hamming, R, M, C, L );
CC=mfccs(:);
MFCCS(1:length(CC),i2)=CC;
[ mfccs2, FBEs2, frames2 ] = ...
mfcc( speech2(:,i2), fs, Tw, Ts, alpha, hamming, R, M, C, L );
CC2=mfccs2(:);
MFCCS2(1:length(CC),i2)=CC2;
end
TrainData =MFCCS;
Group=[0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ];
Group2=zeros(size(Group));
SVMStruct = svmtrain(TrainData,Group); % train
for i3 = 1:length(file)
TestData = MFCCS2(:,i3)';
Group2(1,i3) = svmclassify(SVMStruct,TestData); % test
end
ACC=(16-sum(xor(Group2,Group)))/16;
set(handles.edit1,'string',ACC);
% --- 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 filep
global filename
[filename,filepath]=uigetfile('*.wav','打开文件');%gui中打开文件
filep=strcat(filepath,filename);
%filep
% [filex,fs]=audioread(filep);
% sound(filex,fs);
set(handles.edit2,'string',filename);
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- 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)
global filename
global file
global Group2
for i=1:16
if filename==file(i).name
if Group2(1,i)==1
set(handles.edit3,'string','male');
else if Group2(1,i)==0
set(handles.edit3,'string','female');
else
set(handles.edit3,'string','false');
end
end
end
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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') re
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
mfcc_svm.zip (21个子文件)
MFCC_2
trifbank.m 5KB
mfcc.m 7KB
untitled.m 9KB
vec2frames.m 7KB
Validation_test_set
f2.wav 961KB
f7.wav 1MB
f1.wav 893KB
f3.wav 975KB
f5.wav 1013KB
m3.wav 1022KB
m7.wav 930KB
m1.wav 866KB
m5.wav 1009KB
m4.wav 907KB
f8.wav 957KB
m8.wav 886KB
f4.wav 898KB
f6.wav 1.14MB
m2.wav 772KB
m6.wav 1.01MB
untitled.fig 10KB
共 21 条
- 1
资源评论
- qq_422173342021-05-06主程序函数,不会用
- zhangyang04292019-06-11什么啊……不能用qq_411458362019-06-11在当前文件夹下直接运行主程序untitle.m
- twoyoung1232019-02-23这个怎么用啊qq_411458362019-06-11在当前文件夹下直接运行主程序untitle.m,不会用就直接给一星?
- qq_261224372018-12-19你这个算法判别男性女性不是根据名字来的吗,我把M1改成了F1,然后结果也跟着改变,这代码肯定有问题qq_411458362019-06-11就8个训练样本,正确率只能到达这样了,这个只是个简单的小程序而已,可以根据自己需要修改
- luo200708104182018-07-02SVM算法怎么比较多个时间段的二维数据呢?qq_411458362019-06-11语音数据预处理时提取某一时间段
qq_41145836
- 粉丝: 6
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功