Recording using ‘wavrecord()’:
>> speech = wavrecord(16000, 8000, 1, 'double');
>> sound(speech) % play sound with default sampling rate 8192Hz)
This records 16000 samples with a sample rate of 8kHz in mono (‘1’). (Windows only).
recording using ‘audiorecorder()’:
>> x = audiorecorder(16000, 16, 1);
>> record(x);
% recording ...
>> stop(x); % other commands: pause(), resume()
>> play(x);
>> speech2 = getaudiodata(x, 'double'); %convert to normal vector
16000: Hz, sampling rate (common rates are:8k,11025,22050,44000)
16: sample precision in bits
1: number of channels
The max range values in 16-bit format is -32768~32767. It is scaled to –1.0~1.0 for double precision. If for some reason it is out of range, use following to play instead of ‘sound(speech)’:
>> soundsc(speech, 8000); % or
>> sound(speech / max(abs(speech)), 8000);
>> plot(speech); % or
>> plot([1:size(speech)]/8000, speech); % time in second in x-axis
>> soundsc(speech2, 8000); %or
ReplyDelete.
.
>>plot(speech2); %or
><!