1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
function lpc_training
% This code is for creating the library of Linear Predictive Coding (LPC) features.
Fs = 10000; % Sampling Frequency (Hz)
n = 20; % LPC order
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 = lpc_feature(y,n);
% 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_lpc.mat Fs n words fw; |
Partager