Audio Writing And Saving Location

3 views (last 30 days)
Suleyman Serhani
Suleyman Serhani on 31 Dec 2018
Commented: Walter Roberson on 31 Dec 2018
Hello Everyone,
i recorded my voice with below code and now i must get it for using another matlab code,
how can i get my voice as a mp3 or wav from matlab.
close all; clear all;
% get device information
dev = audiodevinfo;
% create recorder object
seskaydet = audiorecorder(44100, 16, 1);
% start recording
disp('start speaking');
% record(rec, 5); % will record for 5sec. for this command pause needs to be added
recordblocking(seskaydet, 2);
% stop recording
disp('Stop recording');
% Play recorded sound
play(seskaydet);
% get audio data
y = getaudiodata(seskaydet);
% plot the sound
plot(y);

Answers (2)

Walter Roberson
Walter Roberson on 31 Dec 2018
audiowrite('OutputFileNameGoesHere.wav', y, 44100);

Suleyman Serhani
Suleyman Serhani on 31 Dec 2018
thank you i found it,
it save automacally to documents file but my computer however it save to install directory
  1 Comment
Walter Roberson
Walter Roberson on 31 Dec 2018
If by "install directory" you mean the directory that MATLAB itself is installed in, then if you are using MS Windows, you would need to either Run As Administrator or else install MATLAB somewhere outside of the system Program Files directory. MS Windows blocks ordinary users from writing files into the Program Files directories.
You can specify a full path to save the file when you audiowrite it. For example,
audiowrite('C:\Users\suleyman\CS207\MATLAB\Assignmen3\OutFiles\OutputFileNameGoesHere.wav', y, 44100);

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!