saving recorded file in while loop

10 views (last 30 days)
I'm doing a signal processing project in which i need to record user's command and save it in a file as .wav form. After that it should compare the audio file with the saved ones using correlation, and move a robot according to the input command( Using Arduino). The words spoken by the user will be left, right, front, back or stop. These words are already saved in the computer with the user's voice. My code to record the data is as follows:
a=audiorecorder(8000,16,1);
p=1;
while p==1
disp('Enter 1 to record command (speak as soon as you press enter): ');
disp('Enter nothing to stop giving commands');
k=input('');
if k==1
record(a,1);
end
b=getaudiodata(a);
audiowrite('test.wav',b,8000);
if isempty(k)
p=0;
end
end
Error is:
Error using audiorecorder/getaudiodata (line 745)
Recorder is empty.
Error in signalsproject (line 10)
b=getaudiodata(a);
Plse help me My submission is 2mrw

Accepted Answer

Geoff Hayes
Geoff Hayes on 9 Nov 2018
Amulya - the error message is telling you that you haven't recorded anything. You may want to put a breakpoint in the code and then re-run to see what value is being assigned to k. If it isn't 1, then the
record(a,1);
won't be evaluated.
  1 Comment
AMULYA PONNURU 17BIS0031
AMULYA PONNURU 17BIS0031 on 9 Nov 2018
Ooh yaa thanks I resolved the error. The problem was....it is recoreding for 1 second but before recording ...it is trying to get the data So by using a pause command ...the issue is solved.
But i have another doubt :P Can explain in detail about linear predictive coding?? I need to compare a voice that is stored and a voice that is cmng as an input Even though I'm giving both the signals in the same tone....it is recognizing as something else For example I saved four voice samples with left, right, front and back commands. When the give the input voice as left....it is recognizing as right or something else....rarely as left. I did this using correlation. But later understood that it would be better using LPC. So could you kindly help me with my project?? Plse.....

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!