Original Posting Date: October 10, 2012
Give your Cortex-M3 a voice!
Speex is a free audio codec which provides high level of compression with good sound quality for speech encoding and decoding. Speex is an open source and patent-free audio compression format designed for speech. Speex is based on CELP (Code-Excited Linear Prediction) and is designed to compress voice at bitrates ranging from 2 to 44 kbps. Although the Speex codec has been replaced by Opus, we'll here take a look at the Speex audio codec for use with the EFM32 microcontrollers. If you are looking for a codec for interactive speech, music transmission over the Internet, or storage and streaming applications, users are encouraged to switch to the Opus codec.
The EFM32 Speex encoder and decoder are suitable for applications that require low power voice record and/or playback function. Due to the high compression ratio of the Speex encoder, the scalable flash size (up to 1 MB) of EFM32 can fulfill various lengths of voice record and playback. External SPI flash for voice playback data can be eliminated to reduce current consumption (typically 10-17mA during flash read) and simplify the programming (no need to program external SPI flash, only one time programming for application software and voice data in EFM32) and manufacturing process. The rich peripherals of EFM32 (USB, TFT, LCD, AES…) also provide expansion possibilities to many applications that include voice record and/or playback functions.
It is possible to run this software on an EFM32GG-STK3700, by connecting additional hardware to support audio input and a speaker (including external amplifier) to play the output sound. The software examples includes support for the STK, which can be enabled by adding a defined symbol called GG_STK either at the start of main_xxxx.c or in the project defines. The audio output will be played on PB11 (EXP port pin 16) on GG STK, while the AUDIO_OUT jack will be used for the GG_DK.
The Speex encoder example records the audio signal from the AUDIO_IN jack, encodes into Speex format and saves it to internal flash. Operation details are shown in Table 1 and Table 2.
The Speex decoder examples (NB8K, NB, WB and UWB) fetch encoded Speex data from flash, decode it into a digital audio signal which is output to the AUDIO_OUT jack.
• The WAV file “Your blood glucose test result is below” is encoded to different bitrates with 8 kHz, 16 kHz and 32 kHz sampling frequency.
• The header files in “voice” folder are named by bitrate, for example, voice16k8.h means this header file is encoded at quality 5 - wideband 16.8 kbps.
• PB0 in GG STK is used to select bitrate for playback, operation details are shown in Table 3 and Table 4.
The post is written based on the application note ‘Speex Codec.‘ Download the latest full version HERE.