% read internet files
[WORD_oneInternet sampRate6] = ...
wavread('internet1.wav'); %read as a matrix, average out matrix?
[WORD_twoInternet sampRate7] = ...
wavread('internet2.wav');
[WORD_threeInternet sampRate8] = ...
wavread('internet3.wav');
[WORD_fourInternet sampRate9] = ...
wavread('internet4.wav');
[WORD_fiveInternet sampRate10] = ...
wavread('internet5.wav');
% read word files
[WORD_oneWord sampRate11] = ...
wavread('word1.wav'); %read as a matrix, average out matrix?
[WORD_twoWord sampRate12] = ...
wavread('word2.wav');
[WORD_threeWord sampRate13] = ...
wavread('word3.wav');
[WORD_fourWord sampRate14] = ...
wavread('word4.wav');
[WORD_fiveWord sampRate15] = ...
wavread('word5.wav');
%internet
WORD_oneInternet = WORD_oneInternet(:,1);
WORD_twoInternet = WORD_twoInternet(:,1);
WORD_threeInternet = WORD_threeInternet(:,1);
WORD_fourInternet = WORD_fourInternet(:,1);
WORD_fiveInternet = WORD_fiveInternet(:,1);
%word
WORD_oneWord = WORD_oneWord(:,1);
WORD_twoWord = WORD_twoWord(:,1);
WORD_threeWord = WORD_threeWord(:,1);
WORD_fourWord = WORD_fourWord(:,1);
WORD_fiveWord = WORD_fiveWord(:,1);
%internet samp rate
dt6 = 1/sampRate6; % the samp rates should be the same (44,100)
dt7 = 1/sampRate7;
t6 = (0:(length(WORD_oneInternet)-1))*dt6;
t7 = (0:(length(WORD_twoInternet)-1))*dt7;
dt8 = 1/sampRate8; % the samp rates should be the same (44,100)
dt9 = 1/sampRate9;
t8 = (0:(length(WORD_threeInternet)-1))*dt8;
t9 = (0:(length(WORD_fourInternet)-1))*dt9;
dt10 = 1/sampRate10; % the samp rates should be the same (44,100)
t10 = (0:(length(WORD_fiveInternet)-1))*dt10;
% word sample rate
dt11 = 1/sampRate11; % the samp rates should be the same (44,100)
dt12 = 1/sampRate12;
t11 = (0:(length(WORD_oneWord)-1))*dt11;
t12 = (0:(length(WORD_twoWord)-1))*dt12;
dt13 = 1/sampRate13; % the samp rates should be the same (44,100)
dt14 = 1/sampRate14;
t13 = (0:(length(WORD_threeWord)-1))*dt13;
t14 = (0:(length(WORD_fourWord)-1))*dt14;
dt15 = 1/sampRate15; % the samp rates should be the same (44,100)
t15 = (0:(length(WORD_fiveWord)-1))*dt15;
disp('Say a "internet" to open a web browser or "word" to open Microsoft Word')
Fs = 10000;
y = wavrecord(40000,Fs);
disp('End of Recording.');
wavwrite(y,Fs,'input1.wav');
[WORD_input1 sampRate31] = ...
wavread('input1.wav');
WORD_input1 = WORD_input1(:,1);
dt31 = 1/sampRate31;
t31 = (0:(length(WORD_input1)-1))*dt31;
% corellate input with internet
[F21 steps21] = xcorr(WORD_input1,WORD_oneInternet);
maxF21 = max(F21);
[F22 steps22] = xcorr(WORD_input1,WORD_twoInternet);
maxF22 = max(F22);
[F23 steps23] = xcorr(WORD_input1,WORD_threeInternet);
maxF23 = max(F23);
[F24 steps24] = xcorr(WORD_input1,WORD_fourInternet);
maxF24 = max(F24);
[F25 steps25] = xcorr(WORD_input1,WORD_fiveInternet);
maxF25 = max(F25);
% corellate input with word
[F26 steps26] = xcorr(WORD_input1,WORD_oneWord);
maxF26 = max(F26);
[F27 steps27] = xcorr(WORD_input1,WORD_twoWord);
maxF27 = max(F27);
[F28 steps28] = xcorr(WORD_input1,WORD_threeWord);
maxF28 = max(F28);
[F29 steps29] = xcorr(WORD_input1,WORD_fourWord);
maxF29 = max(F29);
[F30 steps30] = xcorr(WORD_input1,WORD_fiveWord);
maxF30 = max(F30);
% find correlation with highest max
A = [maxF21 maxF22 maxF23 maxF24 maxF25 maxF26 maxF27 maxF28 maxF29 maxF30];
maxA = max(A);
if (maxA == maxF21)||(maxA == maxF22)||(maxA == maxF23)||(maxA == maxF24)||(maxA == maxF25)
disp('You said internet. A web browser will now be opened')
web http://www.google.com
elseif (maxA == maxF26)||(maxA == maxF27)||(maxA == maxF28)||(maxA == maxF29)||(maxA == maxF30)
disp('Word will be opened. Please click on Word window to work within Word')
notebook
else
disp('invalid command')
end
% second recording
disp('say record again to say another command')
Fs = 10000;
y = wavrecord(40000,Fs);
disp('End of Recording.');
wavwrite(y,Fs,'input2R.wav');
[WORD_input2R sampRate32] = ...
wavread('input2R.wav');
WORD_input2R = WORD_input2R(:,1);
dt32 = 1/sampRate32; % the samp ra
t32 = (0:(length(WORD_input2R)-1))*dt32;
[WORD_record1 sampRate33] = ...
wavread('record1.wav'); %read as a matrix, average out matrix?
[WORD_record2 sampRate34] = ...
wavread('record2.wav');
[WORD_record3 sampRate35] = ...
wavread('record3.wav');
[WORD_record4 sampRate36] = ...
wavread('record4.wav');
[WORD_record5 sampRate37] = ...
wavread('record5.wav');
WORD_record1 = WORD_record1(:,1);
WORD_record2 = WORD_record2(:,1);
WORD_record3 = WORD_record3(:,1);
WORD_record4 = WORD_record4(:,1);
WORD_record5 = WORD_record5(:,1);
dt33 = 1/sampRate33; % the samp rates should be the same (44,100)
dt34 = 1/sampRate34;
t33 = (0:(length(WORD_record1)-1))*dt33;
t34 = (0:(length(WORD_record2)-1))*dt34;
dt35 = 1/sampRate35; % the samp rates should be the same (44,100)
dt36 = 1/sampRate36;
t35 = (0:(length(WORD_record3)-1))*dt35;
t36 = (0:(length(WORD_record4)-1))*dt36;
dt37 = 1/sampRate37; % the samp rates should be the same (44,100)
t37 = (0:(length(WORD_record5)-1))*dt37;
[R31 steps31] = xcorr(WORD_record1,WORD_record2);
maxR31 = max(R31);
[R32 steps32] = xcorr(WORD_record1,WORD_record3);
maxR32 = max(R32);
[R33 steps33] = xcorr(WORD_record1,WORD_record4);
maxR33 = max(R33);
[R34 steps34] = xcorr(WORD_record1,WORD_record5);
maxR34 = max(R34);
[R35 steps35] = xcorr(WORD_record1);
maxR35 = max(R35);
maxSumR= maxR31+maxR32+maxR33+maxR34+maxR35;
maxAverageR = maxSumR/5;
[R36 steps36] = xcorr(WORD_input2R,WORD_record1);
maxR36 = max(R36);
[R37 steps37] = xcorr(WORD_input2R,WORD_record2);
maxR37 = max(R37);
[R38 steps38] = xcorr(WORD_input2R,WORD_record3);
maxR38 = max(R38);
[R39 steps39] = xcorr(WORD_input2R,WORD_record4);
maxR39 = max(R39);
[R40 steps40] = xcorr(WORD_input2R,WORD_record5);
maxR40 = max(R40);
if (maxR36 >= maxAverageR) || (maxR37 >= maxAverageR) || (maxR38 >= maxAverageR)|| (maxR39 >= maxAverageR) || (maxR40 >= maxAverageR)
disp('Say one of these commands: "find" or "print"')
% next command
Fs = 10000;
y = wavrecord(40000,Fs);
disp('End of Recording.');
wavwrite(y,Fs,'input3.wav');
[WORD_input3 sampRate38] = ...
wavread('input3.wav');
WORD_input3 = WORD_input3(:,1);
dt38 = 1/sampRate38; % the samp ra
t38 = (0:(length(WORD_input3)-1))*dt38;
% read save files
[WORD_oneSave sampRate16] = ...
wavread('save1.wav'); %read as a matrix, average out matrix?
[WORD_twoSave sampRate17] = ...
wavread('save2.wav');
[WORD_threeSave sampRate18] = ...
wavread('save3.wav');
[WORD_fourSave sampRate19] = ...
wavread('save4.wav');
[WORD_fiveSave sampRate20] = ...
wavread('save5.wav');
% read find files
[WORD_oneFind sampRate21] = ...
wavread('find1.wav'); %read as a matrix, average out matrix?
[WORD_twoFind sampRate22] = ...
wavread('find2.wav');
[WORD_threeFind sampRate23] = ...
wavread('find3.wav');
[WORD_fourFind sampRate24] = ...
wavread('find4.wav');
[WORD_fiveFind sampRate25] = ...
wavread('find5.wav');
% read print files
[WORD_onePrint sampRate26] = ...
wavread('print1.wav'); %read as a matrix, average out matrix?
[WORD_twoPrint sampRate27] = ...
wavread('print2.wav');
[WORD_threePrint sampRate28] = ...
wavread('print3.wav');
[WORD_fourPrint sampRate29] = ...
wavread('print4.wav');
[WORD_fivePrint sampRate30] = ...
wavread('print5.wav');
%save
WORD_oneSave = WORD_oneSave(:,1);
WORD_twoSave = WORD_twoSave(:,1);
WORD_threeSave = WORD_threeSave(:,1);
WORD_fourSave = WORD_fourSave(:,1);
WORD_fiveSave = WORD_fiveSave(:,1);
%find
WORD_oneFind = WORD_oneFind(:,1);
WORD_twoFind = WORD_twoFind(:,1);
WORD_threeFind = WORD_threeFind(:,1);
WORD_fourFind = WORD_fourFind(:,1);
WORD_fiveFind = WORD_fiveFind(:,1);
%print
WORD_onePrint= WORD_onePrint(:,1);
WORD_twoPrint = WORD_twoPrint(:,1);
WORD_threePrint = WORD_threePrint(:,1);
WORD_fourPrint = WORD_fourPrint(:,1);
WORD_fivePrint = WORD_fivePrint(:,1);
% save sample rate
dt16 = 1/sampRate16; % the samp rates should be the same (44,100)
dt17 = 1/sampRate17;
t16 = (0:(length(WORD_oneSave)-1))*dt16;
t17 = (0:(length(WORD_twoSave)-1))*dt17;
dt18 = 1/sampRate18; % the samp rates should be the same (44,100)
dt19 = 1/sampRate19;
t18 = (0:(length(WORD_threeSave)-1))*dt18;
t19 = (0:(length(WORD_fourSave)-1))*dt19;
dt20 = 1/sampRate20; % the samp rates should be the same (44,100)
t20 = (0:(length(WORD_fiveSave)-1))*dt20;
% find sample rate
dt21 = 1/sampRate21; % the samp rates should be the same (44,100)
dt22 = 1/sampRate22;
t21 = (0:(length(WORD_oneFind)-1))*dt21;
t22 = (0:(length(WORD_twoFind)-1))*dt22;
dt23 = 1/sampRate23; % the samp rates should be the same (44,100)
dt24 = 1/sampRate24;
t23 = (0:(length(WORD_threeFind)-1))*dt23;
t24 = (0:(length(WORD_fourFind)-1))*dt24;
dt25 = 1/sampRate25; % the samp rates should be the same (44,100)
t25 = (0:(length(WORD_fiveFind)-1))*dt25;
% print sample rate
dt26 = 1/sampRate26; % the samp rates should be the same (44,100)
dt27 = 1/sampRate27;
t26 = (0:(length(WORD_onePrint)-1))*dt26;
t27 = (0:(length(WORD_twoPrint)-1))*dt27;
dt28 = 1/sampRate28; % the samp rates should be the same (44,100)
dt29 = 1/sampRate29;
t28 = (0:(length(WORD_threePrint)-1))*dt28;
t29 = (0:(length(WORD_fourPrint)-1))*dt29;
dt30 = 1/sampRate30; % the samp rates should be the same (44,100)
t30 = (0:(length(WORD_fivePrint)-1))*dt30;
% correlate input with save
[F41 steps41] = xcorr(WORD_input3,WORD_oneSave);
maxF41 = max(F41);
[F42 steps42] = xcorr(WORD_input3,WORD_twoSave);
maxF42 = max(F42);
[F43 steps43] = xcorr(WORD_input3,WORD_threeSave);
maxF43 = max(F43);
[F44 steps44] = xcorr(WORD_input3,WORD_fourSave);
maxF44 = max(F44);
[F45 steps45] = xcorr(WORD_input3,WORD_fiveSave);
maxF45 = max(F45);
% correlate input with find
[F46 steps46] = xcorr(WORD_input3,WORD_oneFind);
maxF46 = max(F46);
[F47 steps47] = xcorr(WORD_input3,WORD_twoFind);
maxF47 = max(F47);
[F48 steps48] = xcorr(WORD_input3,WORD_threeFind);
maxF48 = max(F48);
[F49 steps49] = xcorr(WORD_input3,WORD_fourFind);
maxF49 = max(F49);
[F50 steps50] = xcorr(WORD_input3,WORD_fiveFind);
maxF50 = max(F50);
% correlate input with print
[F51 steps51] = xcorr(WORD_input3,WORD_onePrint);
maxF51 = max(F51);
[F52 steps52] = xcorr(WORD_input3,WORD_twoPrint);
maxF52 = max(F52);
[F53 steps53] = xcorr(WORD_input3,WORD_threePrint);
maxF53 = max(F53);
[F54 steps54] = xcorr(WORD_input3,WORD_fourPrint);
maxF54 = max(F54);
[F55 steps55] = xcorr(WORD_input3,WORD_fivePrint);
maxF55 = max(F55);
% get max correlation
B = [maxF41 maxF42 maxF43 maxF44 maxF45 maxF46 maxF47 maxF48 maxF49 maxF50 maxF51 maxF52 maxF53 maxF54 maxF55];
maxB = max(B);
% MATLAB mixed up the functions when 3 commands were used. So, this section
% is commented out since MATLAB worked fine when there were only 2 commands
% if (maxB == maxF41)||(maxB == maxF42)||(maxB == maxF43)||(maxB == maxF44)||(maxA == maxF45)
% disp('you said save. The page will be saved')
% %import javax.swing.*;
% robot = java.awt.Robot;
% robot.keyPress (java.awt.event.KeyEvent.VK_CONTROL);
% robot.keyPress (java.awt.event.KeyEvent.VK_S);
% robot.keyRelease (java.awt.event.KeyEvent.VK_CONTROL);
% robot.keyRelease (java.awt.event.KeyEvent.VK_S);
if (maxB == maxF46)||(maxB == maxF47)||(maxB == maxF48)||(maxB == maxF49)||(maxA == maxF50)
disp('you said find. The find command will now execute')
%import javax.swing.*;
robot = java.awt.Robot;
robot.keyPress (java.awt.event.KeyEvent.VK_CONTROL);
robot.keyPress (java.awt.event.KeyEvent.VK_F);
robot.keyRelease (java.awt.event.KeyEvent.VK_CONTROL);
robot.keyRelease (java.awt.event.KeyEvent.VK_F);
else %if (maxB == maxF51)||(maxB == maxF52)||(maxB == maxF53)||(maxB == maxF54)||(maxA == maxF55)
disp('you said print. The print command will now execute')
%import javax.swing.*;
robot = java.awt.Robot;
robot.keyPress (java.awt.event.KeyEvent.VK_CONTROL);
robot.keyPress (java.awt.event.KeyEvent.VK_P);
robot.keyRelease (java.awt.event.KeyEvent.VK_CONTROL);
robot.keyRelease (java.awt.event.KeyEvent.VK_P);
% else
% disp('invalid command')
end
else
disp('goodbye')
end
No comments:
Post a Comment