Close

Speech codec

A project log for digital-walkie-talkie

long range, low power, modular

Christoph TackChristoph Tack 08/09/2020 at 14:480 Comments

 As the walkie talkie will use digital voice transmission, we need a way to digitize speech.  Several open source speech codecs are available.  We will focus on low-bitrate codecs because we want long range.  Opus and Speex won't do.  There's one codec that excels : codec2 :

Installation on Ubuntu

sudo apt install codec2

Some experiments

After installation of codec2, the raw audio file test samples are available in /usr/share/codec2/raw

I tried playing with the 700bps bitrate, but that never yielded results that were easily understandable.  If you had a conversation with someone using this bitrate, you would frequently have to ask to repeat sentences.

1200bps seems to me the minimum practically achievable bitrate.

christoph@christoph-ThinkPad-L580:/usr/share/codec2/raw$ c2enc 1200 ve9qrp.raw ~/ve9qrp.bit --natural && c2dec 1200 ~/ve9qrp.bit ~/ve9qrp_codec2_1200.raw --natural && aplay -f S16_LE ~/ve9qrp_codec2_1200.raw <br><br> 
max_amp: 80 m_pitch: 320
p_min: 20 p_max: 160
Wo_min: 0.039270 Wo_max: 0.314159
nw: 279 tw: 40
max_amp: 80 m_pitch: 320
p_min: 20 p_max: 160
Wo_min: 0.039270 Wo_max: 0.314159
nw: 279 tw: 40
Playing raw data '/home/christoph/vk5qi_codec2_1200.raw' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
christoph@christoph-ThinkPad-L580:/usr/share/codec2/raw$ 

For your audio playback convenience, these raw files have been converted to WAV-file format using:

sox -e signed-integer -b 16 -r 8000 -c 1 ve9qrp.raw ~/ve9qrp.wav

File sizes:

So we see that codec2 achieves a 128k/1.2k = 106.7/1 compression ratio.  That's truly impressive.

Of course, this compression ratio comes at a price : computational complexity.  There's no way you could pull this off in real time with an AVR-microcontroller.  You need at least an MCU with an FPU, such as the STM32F4.  An ESP32 doesn't seem suited either.  A Raspberry Pi could be used at the cost of higher current consumption.

Discussions