lunatechian (lunatech-ian)

one relating to, belonging to, or resembling lunatech

converting spx to mp3

Since my constant companion, the video ipod, cannot play Speex format, I needed to convert a bunch of files .spx files to mp3 format.

This shell script should do the work for you (it will work for files with spaces in them)

sudo find ./ -name '*.spx' | while read FILE; do ogg123 -d wav -f - "$FILE" | lame - "$FILE.mp3" ; done

The -d wav -f - argument to ogg123 make it(ogg123) use the WAV driver and output the result to the stdout (given by -f -). The stdout from ogg123 is passed to lame, which converts the wav to mp3. Caveat: The id3 info in the spx file is lost and you have to add that to the mp3 files manually.

One interesting thing I came to know in this was how to loop over files with spaces in them. This is done by piping the result of find to the while read part. More details of this is here