?? xianchangsb.m
字號:
%現場識別的實現
clear;
clc;
fs=11025; % 取樣頻率
duration=2; % 錄音時間
load d:\D:\speech_toolboxes\HMM\hmm
x=wavrecord(duration*fs, fs);
[x1 x2] = vad(x);
m = mfcc(x);
m = m(x1-2:x2-2,:);
for j=1:10
pout(j) = viterbi(hmm{j}, m);
end
[d,n] = max(pout);
if n==10
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 0 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\10.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else
if n==1
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 1 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\1.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==2
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 2 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\2.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==3
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 3 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\3.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==4
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 4 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\4.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==5
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 5 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\5.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==6
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 6 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\6.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==7
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 7 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\7.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==8
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 8 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\8.wav');
[s,fs] = wavread(fname);
sound(s,fs);
else if n==9
uicontrol('Style','text',...
'Position',[230 10 340 270],...
'String','識別結果為: 9 ',...
'FontSize',20.,...
'Callback',[]);
fname = sprintf('\\HMM\\9.wav');
[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 + -