how to convert a .mp3 to .wav file in matlab?
Show older comments
i need to know about how to convert a single .mp3 audio file to a single .wav file in matlab? what code i have to use?
i had using this code:
filename=audioread('C:\Users\Rini Indrayani\Documents\MATLAB\Matlab\asli4.mp3');
audiowrite(filename,'C:\Users\Rini Indrayani\Documents\MATLAB\Matlab\hasilwav4.wav');
but the matlab shows error:
Error using audiowrite (line 100)
Not enough input arguments.
what should i do? i am a newbie in matlab. need a help. thanks
1 Comment
JIkrul Sayeed
on 14 Feb 2020
mp3filename = 'C:\Users\samuraiX\Desktop\Work\mp3towav\Music.mp3';
wavFileName = 'C:\Users\samuraiX\Desktop\Work\mp3towav\aMusic.wav';
signal = audioread(mp3filename);
info = audioinfo(mp3filename);
Fs = info.SampleRate;
audiowrite(wavFileName, signal, Fs);
Answers (3)
Use meaningful names for variables. audioread does not reply a file name.
filename = 'C:\Users\Rini Indrayani\Documents\MATLAB\Matlab\asli4.mp3';
signal = audioread(filename);
When you get an error concerning a command, the first thing you should do is reading the documentation:
doc audiowrite
There you find that this is the minimal calling sequence:
audiowrite(filename,y,Fs)
So you need:
wavFileName = 'C:\Users\Rini Indrayani\Documents\MATLAB\Matlab\hasilwav4.wav';
audiowrite(wavFileName, signal, 44100);
info = audioinfo(filename);
info.SampleRate
Summary: Do not guess how the commands work, but read the instructions in the help or doc text.
KSSV
on 24 May 2017
0 votes
Use mp3read from https://in.mathworks.com/matlabcentral/fileexchange/6152-mp3write-and-mp3read...and then you have data in hand..try converting it to .wav.
Dheeraj M Pai
on 9 Sep 2017
0 votes
For linux there is no good package
Thanks
1 Comment
Walter Roberson
on 9 Sep 2017
? audioread() and audiowrite() should work in Linux. However, with some releases of MATLAB and some versions of Linux, you might have conflicts with gstreamer versions and so might need to install a different version of gstreamer.
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!