Naveen Cherian
Naveen Cherian

Reputation: 49

wav playback in Matlab while recording speech

I am facing problem while recording speech for 5 seconds. I have sucessfully played back using play() function , but once i play the wav file i have saved on my desktop,it is nothing but silence. This is the code

clc,clear;
% Record your voice for 5 seconds.
%recObj = audiorecorder;
recObj = audiorecorder(96000, 16, 1);
disp('Start speaking.')
recordblocking(recObj,5);

disp('End of Recording.');`enter code here`
% Play back the recording.
play(recObj);
myspeech = getaudiodata(recObj,'double');
wavwrite(double(myspeech),'C://Users//naveen//Desktop//unprocessed')

% Store data in double-precision array.
myRecording = getaudiodata(recObj);

% Plot the samples.
figure,plot(myRecording),title('Original Sound');

Upvotes: 0

Views: 464

Answers (1)

RTL
RTL

Reputation: 3587

wavwrite is called with out a sample rate specified and the default is 8000Hz

however the recording is set to 96000Hz in your call to audiorecorder

audiorecorder(96000, 16, 1);

Changeing these two to match should fix the issue so change either of the calls to one of the following

recObj = audiorecorder(8000, 16, 1)
wavwrite(double(myspeech),96000,'C:/...snip... 

As an added note I think myspeech is already double (as specified in getaudiodata) so wavwrite(myspeech,96000,'C:/...snip... should work just as well!

Upvotes: 1

Related Questions