%% Record and Play Audio Sample
% Record audio data from a microphone and then play the recorded audio.
% Create an audiorecorder object with default property values.

recObj = audiorecorder;

% Record a five second sample of your speech with your microphone.

disp('Start speaking.')
recordblocking(recObj,5);
disp('End of Recording.');

% Create an audio player object from the recording and then play the recorded sample.

playerObj = audioplayer(recObj);
play(playerObj);

% Copyright 2018 The MathWorks, Inc.