function bof_training
% This code is for creating the library of Bank of Filters (BOF) features.
% get a word from microphone
Fs = 10000; % Sampling Frequency (Hz)
n = 100; % Number of filters (frequency bands)
Nseconds = 1; % Length of speech signal
% List of words (you can add more words to this list but make sure
% each word has five characters (if less then pad it with spaces)
words = [' up';
' down';
' left';
'right'];
% Matrix to store features for each word (rows correspond to words)
fw = zeros(size(words,1),n);
fprintf('You will get one second to say each word.\n\n');
% For each word, get the word from microphone and compute its features
for i=1:size(words,1)
fprintf('Hit enter and say immediately ''%s'':',words(i,:));
% pause for enter key
junk=input('');
% get a word from microphone
y = wavrecord(Nseconds*Fs, Fs, 'double');
% Calculate the features of the word
f = bof_feature(y,n,Fs);
% Save them in the features matrix
fw(i,:) = f;
% abs(f)
% plot(1:Fs,fft(y));
end
% Save features matrix to a file (this file will be loaded into Matlab during speech recognition)
save words_bof.mat Fs n words fw;