?? xianchangsb.m
字號:
%現場識別的實現
clear;
clc;
for i=1:10
fname = sprintf('..\\DTW\\%dc.wav',i-1);
x = wavread(fname);
[x1 x2] = vad(x);
m = mel(x);
m = m(x1-2:x2-2,:);
ref(i).mel = m;
end
fs=22050; % 取樣頻率
duration=2; % 錄音時間
x=wavrecord(duration*fs, fs);
[x1 x2] = vad(x);
m = mel(x);
m = m(x1-2:x2-2,:);
test(i).mel = m;
disp('正在進行模板匹配...')
dist = zeros(10,10);
i=1
for j=1:10
dist(i,j) = dtw(test(i).mel, ref(j).mel);
end
disp('正在計算匹配結果...')
[d,j] = min(dist(i,:));
fprintf('系統的識別結果為:%d\n',j-1);
if j-1==0
fname = sprintf('\\DTW\\0.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 0 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==1
fname = sprintf('\\DTW\\1.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 1 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==2
fname = sprintf('\\DTW\\2.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 2 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==3
fname = sprintf('\\DTW\\3.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 3 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==4
fname = sprintf('\\DTW\\4.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 4 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==5
fname = sprintf('\\DTW\\5.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 5 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==6
fname = sprintf('\\DTW\\6.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 6 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==7
fname = sprintf('\\DTW\\7.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 7 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==8
fname = sprintf('\\DTW\\8.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 8 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
else if j-1==9
fname = sprintf('\\DTW\\9.wav');
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 9 ',...
'FontSize',20.,...
'Callback',[]);
[s,fs] = wavread(fname);
sound(s,fs);
end
end
end
end
end
end
end
end
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -