% SURAJ BASTOLA %%%%%%%%%%%%
%%% RECORDING AND SAVING RECORDED AUDIO %%%%%%
% =======================Recording Audio and Saving it to some location================
audio = audiorecorder(8000,8,1); % y = audiorecorder(Fs,nbits,channels)
fprintf('start speaking\n')
%%%% Stopping record after 10 seconds %%%%%%%%
recordblocking(audio,10); % recordblocking(recorderObj, length)
fprintf('End of recording\n')
%%%%% Getting data from audiorecorder Object and saving it to specified folder location %%%%%%%%%%%
myrec= getaudiodata(audio); % y = getaudiodata(recorder)
audiowrite('C:\Users\suraj\OneDrive\Documents\MIT COLLEGE\Software Defined Radio Communication\MATLAB COding\audioRecorded.wav', myrec, 8000);
fprintf('successfully saved the recorded audio');
% ========================Loading recorded audio by retrieving from saved location ===================
[y,Fs] = audioread('C:\Users\suraj\OneDrive\Documents\MIT COLLEGE\Software Defined Radio Communication\MATLAB COding\audioRecorded.wav');
sound(y,8000); % Playing retrieved audio
fprintf('successfully played the retrieved recorded audio\n')
% ===== Plotting the audio %%%%%%%%%%%
plot(y)
title('Recorded Audio of 10 seconds')
No comments:
Post a Comment