bidyutkalita
Newbie level 1
- Joined
- Jun 4, 2013
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,303
i am doing a project speech controlled robotic car ..i have written code for parallel communication.
here are the code
%%%%%%%% Training Process %%%%%%%%
% Prepare the user to record voice
'record your commands'
l=0;
m=0;
avg=0;
for j=1:4
'record command'
disp(j)
input ('You will have 2 seconds to command. Press enter when ready')
% Record Voice
usertemp = wavrecord (88200,44100);
sound (usertemp,44100);
'';
plot(usertemp);
count=0;
for n=2:44100
if(usertemp(n,1)<=0.4)%0.02
%p(n,1)=0;
else
%p(n,1)=1;
count=count+1;
end
end
avg(1,j)=count;
disp(avg(1,j))
count=0;
usertemp=0;
end
%%%%%%%% Verification Process %%%%%%%%
%clear;
parport=digitalio('parallel','LPT1');
addline(parport,0:7,'out');
% Prepare the user to record voice
input ('You will have 2 seconds to command. Press enter when ready')
% Record Voice and confirm if the user is happy with their recording
usertemp = wavrecord (88200,44100);
sound (usertemp,44100);
'';
rec = input ('Are you happy with this recording? \nIf not Press 1 to record again or just press enter to proceed--> ');
while rec == 1
rec = 0;
input ('You will have 2 seconds to command. Press enter when ready')
usertemp = wavrecord (88200,44100);
sound (usertemp,44100);
rec = input ('Are you happy with this recording? \nIf not Press 1 to record again or just press enter to proceed--> ');
end
%plot(usertemp);
count=0;
for n=2:44100
if(usertemp(n,1)<=0.4)%0.02
% P(n,1)=0;
else
%P(n,1)=1;
count=count+1;
end
end
disp(count);
if count<=(avg(1,1)+500) & count>=(avg(1,1)-500)
disp('forward')
putvalue(parport,5);
pause(.4);
putvalue(parport,0);
elseif count<=(avg(1,2)+500) & count>=(avg(1,2)-500)
disp('left')
putvalue(parport,1);
pause(.3);
putvalue(parport,0);
elseif count<=(avg(1,3)+500) & count>=(avg(1,3)-500)
disp('right')
putvalue(parport,4);
pause(.3);
putvalue(parport,0);
elseif count<=(avg(1,4)+500) & count>=(avg(1,4)-500)
disp('back')
putvalue(parport,10);
pause(.4);
putvalue(parport,0);
else
disp('speak again')
putvalue(parport,0);
end
count=0;
a=input('press any key to continue.....');
voicecomp;
now i am facing for serial communication .for serial communication how to write code and what hardware will have need for this interface,please suggest me.
here are the code
%%%%%%%% Training Process %%%%%%%%
% Prepare the user to record voice
'record your commands'
l=0;
m=0;
avg=0;
for j=1:4
'record command'
disp(j)
input ('You will have 2 seconds to command. Press enter when ready')
% Record Voice
usertemp = wavrecord (88200,44100);
sound (usertemp,44100);
'';
plot(usertemp);
count=0;
for n=2:44100
if(usertemp(n,1)<=0.4)%0.02
%p(n,1)=0;
else
%p(n,1)=1;
count=count+1;
end
end
avg(1,j)=count;
disp(avg(1,j))
count=0;
usertemp=0;
end
%%%%%%%% Verification Process %%%%%%%%
%clear;
parport=digitalio('parallel','LPT1');
addline(parport,0:7,'out');
% Prepare the user to record voice
input ('You will have 2 seconds to command. Press enter when ready')
% Record Voice and confirm if the user is happy with their recording
usertemp = wavrecord (88200,44100);
sound (usertemp,44100);
'';
rec = input ('Are you happy with this recording? \nIf not Press 1 to record again or just press enter to proceed--> ');
while rec == 1
rec = 0;
input ('You will have 2 seconds to command. Press enter when ready')
usertemp = wavrecord (88200,44100);
sound (usertemp,44100);
rec = input ('Are you happy with this recording? \nIf not Press 1 to record again or just press enter to proceed--> ');
end
%plot(usertemp);
count=0;
for n=2:44100
if(usertemp(n,1)<=0.4)%0.02
% P(n,1)=0;
else
%P(n,1)=1;
count=count+1;
end
end
disp(count);
if count<=(avg(1,1)+500) & count>=(avg(1,1)-500)
disp('forward')
putvalue(parport,5);
pause(.4);
putvalue(parport,0);
elseif count<=(avg(1,2)+500) & count>=(avg(1,2)-500)
disp('left')
putvalue(parport,1);
pause(.3);
putvalue(parport,0);
elseif count<=(avg(1,3)+500) & count>=(avg(1,3)-500)
disp('right')
putvalue(parport,4);
pause(.3);
putvalue(parport,0);
elseif count<=(avg(1,4)+500) & count>=(avg(1,4)-500)
disp('back')
putvalue(parport,10);
pause(.4);
putvalue(parport,0);
else
disp('speak again')
putvalue(parport,0);
end
count=0;
a=input('press any key to continue.....');
voicecomp;
now i am facing for serial communication .for serial communication how to write code and what hardware will have need for this interface,please suggest me.