how to convert a .mp3 to .wav file in matlab?

조회 수: 17 (최근 30일)
Rini Indrayani
Rini Indrayani 2017년 5월 24일
댓글: JIkrul Sayeed 2020년 2월 14일
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
JIkrul Sayeed
JIkrul Sayeed 2020년 2월 14일
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);

댓글을 달려면 로그인하십시오.

답변 (3개)

Jan
Jan 2017년 5월 24일
편집: Jan 2017년 5월 24일
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);
if this is the right frequency. You can find this by audioinfo:
info = audioinfo(filename);
info.SampleRate
Summary: Do not guess how the commands work, but read the instructions in the help or doc text.

KSSV
KSSV 2017년 5월 24일
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
Dheeraj M Pai 2017년 9월 9일
For linux there is no good package
Thanks
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 9월 9일
? 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by