MATRIX Voice Detection PocketSphinx on Raspberry Pi

Here we will setup speech detection using Pocketsphinx on your Raspberry Pi with MATRIX Voice.

PocketSphinx is an easy to use speech recognition engine, mainly focused on IOT and mobile devices. PocketSphinx is actually a library that works hand in hand with another library ‘SphinxBase’ which provides common functionality across all CMUSphinx projects. To setup Pocketsphinx, you have to install both Pocketsphinx as well as Sphinxbase.

Video Demo

You like this video, click the subscribe below to subscribe my youtube channel for future updates.

 Components Needed


Step 1 : Setting Up Raspberry Pi

Download and burn latest Raspbian image to a micro SD card and insert it into the raspberry Pi.

Now power it up with a power adapter that can provide at least 2.5 Ampere. Now fire up your terminal and create a password for the user ‘pi’ by executing the command

sudo passwd pi

Connect your Raspberry Pi to a WiFi router or Wired network and make sure it is connected by checking whether it is getting an IP address from the switch.

Now perform and update and upgrade by running

sudo apt update -y 
sudo apt upgrade -y
sudo apt install npm oracle-java8-jdk
Step 2 : Install MATRIX Malos

Follow Steps 3, 4, 6, 7 and 8 of this tutorial to install MATRIX Malos. Once you finish installing, reboot you raspberry pi.

When the pi boots up, malos should be running as a service on the backgroud.

Step 3 : Install Matrixio Malos Wakeword
sudo apt install matrixio-malos-wakeword git build-essential cmake

After performing installation, do a reboot.

After the reboot, matrix-malos and matrix-malos-wakeword should be running as service. You can check that by running

ps aux | grep -i malos
Step 4 : Download and Build PocketSphinx Scripts
git clone
cd matrix-creator-pocketsphinx
mkdir build 
cd build
cmake .. 
make -j $(nproc)
Step 5 : Setting Up Language and Dictionary

Create a folder “assets” inside matrix-creator-pocketsphinx/build/demos

cd matrix-creator-pocketsphinx/build/demosmkdir assets

Download a sample dictionary form here, extract it and place it inside “assets” folder.

Step 6 – Running the Demo

Now go inside matrix-creator-pocketsphinx/build/demos folder and start running the script using below command

./pocketsphinx_demo -keyphrase "MATRIX" -kws_threshold 1e-20 -dict assets/6706.dic -lm assets/6706.lm -inmic yes -adcdev mic_channel8


You like this video, click the subscribe below to subscribe my youtube channel for future updates.

 Adding Your Own keywords
Create your own wordlist as save it as a file as shown below
startstoppowerdownrobot startrobot stoplights onlights offcamera streamstart voice record

Upload this file to Sphinx Knowledge Base Tool and click on “Compile Knowledge Base”. You will be provided with some new asset files.

Dowload the file and update assets folder.

If you are stuck somewhere or have anyquestions, please feel free to ask it in our community.


Add a Comment

Your email address will not be published. Required fields are marked *