Skip to content

Convert an MP3 File to WAV Format Linux (Debian/ubuntu/CentOS)

There are lots of tools that to convert a MP3 file into WAV format. I recommend mpg321 which is a free command-line mp3 player, which uses the mad audio decoding library. Install mpg321 or mpg123 Type the following command under Debian / Ubuntu Linux, Use:

sudo apt-get install mpg321

OR

sudo apt-get install mpg123

I recommend using mpg123 as it is updated frequently. Install mpg123 under CentOS / RHEL / Fedora Linux Turn on rpmforge repo and type the following command:

yum install mpg123

Convert an MP3 to WAV The -w option will convert an .mp3 file to .wav file. The syntax is:

mpg123 -w output.wav input.mp3

OR

mpg321 -w output.wav input.mp3

A Sample Shell Script Helper Function Add the following to your ~/.bashrc startup file: Open your .bashrc file and put this code at the end of the file.

$ vi ~/.bashrc
mp3towav(){
[[ $# -eq 0 ]] && { echo "mp3wav mp3file"; exit 1; }
for i in "$@"
do
# create .wav file name
local out="${i%/*}.wav"
[[ -f "$i" ]] && { echo -n "Processing ${i}..."; mpg123 -w "`echo $out|sed -e s/\.mp3//`" "$i" &>/dev/null && echo "done." || echo "process failed."; }
done
}

Then execute the .bashrc file using source command to make changes.

$ source ~/.bashrc

Use it as follows:

mp3towav *.mp3