Home‎ > ‎Tom's Ideas And Notes‎ > ‎

Convert mp3 (or ogg) to speex spx file

posted Nov 20, 2011, 11:47 AM by Tom Gutwin   [ updated Nov 20, 2011, 12:10 PM ]
Audio File Icon
Recently I wanted to convert a audio mp3 file that is primarily voice to speex spx format to save disk space.

It can be done on the command line in one command if you know what parameters to use for the mpg123 and speexenc commands.
   mp3-decoder -q -s -r 16000 inputFile.mp3 | speexenc --vbr -w --author "Author" --title "ProgramTitle" - outputFile.spx

The trick to this is the
   -r 16000
and
   -w
These set the bitrates that the decoder and encoder use. They have to match each other.
if you use -r 32000 then you have to use -u on the speexenc command
if you use -r 8000 then you have to use -n on the speexenc command

This quickly and directly converts a mp3 file (i.e. radio show podcast) to a speex file that uses less than 1/5th the disk space.

If it is a Vorbis ogg file the command line would be...
   oggdec -Q -b 16 inputFile.ogg | speexenc --vbr -w --author "Author" --title "ProgramTitle" - outputFile.spx

Comments