Speex
37c3317fd058; modified for Encode Wiki · CC BY-SA 4.0Speex is a lossy speech codec from Xiph, designed for VoIP and other low-bitrate voice. Xiph’s own site says it has been obsoleted by Opus, which is better in every respect, and the last release (1.2.1) dates from 2022. Don’t use Speex for new work. The only reasons to touch it are playing or converting old .spx files and talking to legacy VoIP equipment.
Speex works at three sampling rates: narrowband (8 kHz), wideband (16 kHz) and ultra-wideband (32 kHz). It handles speech, not music, and its quality is poor outside that. SpeexDSP, the companion library with resampling, echo cancellation and noise suppression, is separate and still used.
Encoding and decoding
Section titled “Encoding and decoding”With the reference tools:
speexenc --wideband --quality 8 input.wav output.spxspeexdec output.spx output.wav--narrowband, --wideband and --ultra-wideband say which rate the input is (8, 16 or 32 kHz); resample first, since speexenc warns about other rates. --quality goes 0–10.
With FFmpeg (needs libspeex):
ffmpeg -i speech.wav -ar 16000 -c:a libspeex -b:a 24k speech.spxFFmpeg’s wrapper also exposes -vad and -dtx (voice activity detection and discontinuous transmission), -abr 1 (average bitrate), -frames_per_packet (1–8) and -compression_level (0–10, default 3). It accepts mono or stereo at 8, 16 or 32 kHz.
Migrating to Opus
Section titled “Migrating to Opus”Re-encoding Speex to Opus decodes and recompresses lossy audio, so keep the originals and expect some extra loss. Opus handles speech well at 24–32 kbit/s mono. .spx files use the Ogg container. Browsers do not play them natively.