Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is a good way to convert mp3 files to speex files? I'll favor answers that give an easy solution for converting multiple files at a time and/or maintain good quality for spoken audio. Though any solution will be appreciated since I haven't found even a difficult way that works.

share|improve this question
up vote 1 down vote accepted

Example for processing all mp3 files in current folder to speex using wide band (input rate converted to 16KHz with best SRC available - SoX):

for f in *.mp3 ; do sox "$f" -r 16k -t wav - | speexenc -w - "${f%.*}.speex" ; done

Depending on preferences change speex option and/or SoX rate converter to appropriate setting. For spoken audio example wide band should be fine

share|improve this answer
I also needed to install sox (obvious) and also libsox-fmt-all (not so obvious). Though libsox-fmt-mp3 would probably have covered it in this case. – Rob Mosher Nov 11 '11 at 12:45
Yes, I presumed that SoX is present, like anywhere someone is doing something with audio, other than listening. I don't know what's the purpose of your task, but you may be interested also in OPUS (former Celt) by known developers: Listening tests outperformed everything available (Vorbis aoTuV, Apple HE AAC, ...) although bitstream is not frozen yet, it's generally available to public – zetah Nov 11 '11 at 13:34
It should be noted that the speex files produced by this command line will retain none of the metadata from the mp3 files. – Christian Mar 22 '14 at 4:54

You can use ffmpeg:

lame filename.mp3 filename.wav
ffmpeg -i  filename.wav filename.spx


share|improve this answer

Although Opus is a better option these days you can use FFmpeg (if configured with --enable-speex):

for f in *.mp3
  ffmpeg -i "$f" -ar 32000 -q:a 10 "${f%.mp3}.spx"

This produced quite reasonable audio on my setup....

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.