AMH9
AMH9

Reputation: 179

wave audio file that recorded from matlab sound differently

I have an issue in exporting audio file recorded using matlab, when I record my voice and play it back it sound fine, but when I save it - export the audio - as a wav file and play it either by playing that exported file or read it again using matlab, it sound differently, the length is shorter and speech is faster and sound funny, how can I fix this?

voice = audiorecorder;
disp('Start speaking.')
recordblocking(voice, 5);
disp('End of Recording.');

play(voice);
y = getaudiodata(voice);

filename = 'myvoicerecord.wav';
audiowrite(filename,y,Fs);

Upvotes: 0

Views: 1531

Answers (2)

mehmet
mehmet

Reputation: 1631

The variable Fs cause this problem. I mean the sampling frequency is different from the value Fs when you record your voice.

Use the code below:

Fs       = e4                                 % // Sampling frequency: 10000 Hz
bits     = 16;                                % // Bits Per Sample: 16
channel  = 1;                                 % // Number of Channels: Mono
rec_time = 5;                                 % // Block of Sample Time: 5 sec
voice    = audiorecorder(Fs, bits, channel);  % // Recorder object
record(voice);                                % // Start Recording
pause(rec_time);                              % // Recording
stop(voice);                                  % // Stop Recording
play(voice);

y        = getaudiodata(voice);
filename = 'myvoicerecord.wav';
wavwrite(y, Fs, bits, filename);

Upvotes: 2

RGHummel
RGHummel

Reputation: 58

Sounds like an issue to do with your sampling frequency. What's 'Fs' here? I'm not familiar with the 'getaudiodata' routine but I bet it tells you or lets you specify the sampling frequency.

Upvotes: 1

Related Questions