[Solved] Kitt_ai wakeword engine still not working on Matrix VOICE

The last time I tried Everloop, I had to load the module.

sudo modprobe matrixio-everloop
sudo chmod 666 /dev/matrixio_everloop

And again from scratch, result: FAIL :frowning:

Install Stretch
curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -
echo “deb https://apt.matrix.one/raspbian $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/matrixlabs.list
sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove
sudo apt install libmatrixio-creator-hal-dev
cd /home/pi/Desktop
git clone https://github.com/matrix-io/alexa-avs-sample-app.git
cd alexa-avs-sample-app
. automated_install.sh
Y
Y
Y
ProductID
ClientID
ClientSecret
Y
1
1
Y
Fail, so:
sudo ldconfig
cd /home/pi/Desktop/alexa-avs-sample-app/samples/wakeWordAgent/src
make clean
cmake .
make
sudo apt install matrixio-creator-init
sudo apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel git _
sudo reboot
git clone https://github.com/matrix-io/matrixio-kernel-modules
cd matrixio-kernel-modules
make && make install
Add in /boot/config.txt: dtoverlay=matrixio
sudo apt-get install cmake g++ git libfftw3-dev wiringpi matrixio-creator-init libgflags-dev
git clone --recursive https://github.com/matrix-io/matrix-creator-hal.git
cd matrix-creator-hal && mkdir build && cd build
cmake …
make && sudo make install
git clone https://github.com/matrix-io/matrix-creator-hal.git
cd matrix-creator-hal
git fetch
git checkout ac/kernel_space
mkdir build && cd build
cmake …
make
sudo make install
sudo rm /etc/asound.conf
sudo nano ~/.asoundrc

pcm.!default {
_ type asym

_ capture.pcm “mic”_
_ playback.pcm “speaker”_
}
pcm.mic {
_ type softvol_
_ slave {_
_ pcm “array”_
_ }_
_ control {_
_ name “MicArray Master”_
_ card 0_
_ }_
}
pcm.speaker {
_ type plug_
_ slave {_
_ pcm “hw:0,0”_
_ }_
}
pcm.array {
_ type plug_
_ slave {_
_ pcm “hw:2,0”_
_ }_
}

sudo apt-get install python-pyaudio python3-pyaudio sox
pip install pyaudio

_ Terminal 1_
cd ~/Desktop/alexa-avs-sample-app/samples
cd companionService && npm start

_ Terminal 2_
cd ~/Desktop/alexa-avs-sample-app/samples
cd javaclient && mvn exec:exec

_ Terminal 3_
cd ~/Desktop/alexa-avs-sample-app/samples
cd wakeWordAgent/src && ./wakeWordAgent -e kitt_ai

-> cant open device

:frowning: close.

you also need:

sudo apt install matrixio-creator-init
sudo reboot

ignore the above: you have installed it,

but you should build the wakeword engine after you have installed the hal from git, not before, so it uses the correct everloop implementation.

cd /home/pi/Desktop/alexa-avs-sample-app/samples/wakeWordAgent/src
make clean
cmake .
make

./wakeWordAgent -e kitt_ai
gives:
INFO:KittAiSnowboyWakeWordEngine: thread started
INFO:WakeWordIPCSocket::mainLoop thread started
INFO:WakeWordIPCSocket: init socket on port:5123
INFO:===> Connected to AVS client <===
Segmentation fault

Damn. In my test i completely disabled the everloop, maybe you can try this:

Modify the WakeWordAgent.cpp and comment out the everloop stuff.

--- a/samples/wakeWordAgent/src/WakeWordAgent.cpp
+++ b/samples/wakeWordAgent/src/WakeWordAgent.cpp
@@ -69,14 +69,14 @@ WakeWordAgent::~WakeWordAgent() {
 // transition should be self-explanatory.
 void WakeWordAgent::mainLoop() {
 
-  hal::WishboneBus bus;
+  /* hal::WishboneBus bus;
 
   bus.SpiInit();
 
   hal::Everloop everloop;
   hal::EverloopImage image1d;
 
-  everloop.Setup(&bus);
+  everloop.Setup(&bus);*/
 
   log(Logger::INFO, "WakeWordAgent: thread started");
 
@@ -99,13 +99,13 @@ void WakeWordAgent::mainLoop() {
         case State::WAKE_WORD_DETECTED:
           m_IPCHandler->sendCommand(Command::WAKE_WORD_DETECTED);
           setState(State::SENT_WAKE_WORD_DETECTED);
-          for (hal::LedValue& led : image1d.leds) {
-            led.red = 50;
+          /*for (hal::LedValue& led : image1d.leds) {
+            led.red = 0;
             led.green = 0;
-            led.blue = 0;
+            led.blue = 10;
             led.white = 0;
           }
-          everloop.Write(&image1d);
+          everloop.Write(&image1d);*/
           break;
 
         case State::WAKE_WORD_PAUSE_REQUESTED:
@@ -117,13 +117,13 @@ void WakeWordAgent::mainLoop() {
         case State::WAKE_WORD_RESUME_REQUESTED:
           m_wakeWordEngine->resume();
           setState(State::IDLE);
-          for (hal::LedValue& led : image1d.leds) {
+          /*for (hal::LedValue& led : image1d.leds) {
             led.red = 0;
             led.green = 0;
-            led.blue = 50;
+            led.blue = 0;
             led.white = 0;
           }
-          everloop.Write(&image1d);
+          everloop.Write(&image1d);*/
           break;
 
         default:

then recompile it with the commands above.

Error is gone. Does not respond to the wakeword, but I need to do some more testing… (lots of noise in recording, but audible).
THANKS! We r getting close :wink:

Recordings with:
arecord -D default -f S16_LE test.wav
aplay -D default test.wav
are full of static noise - could that be an/the issue?

Yes, noise is always bad :slight_smile:
Can you record from different channels and share the wav files here.
Thank you.

Hi, for that I need Malos installed and that doesnt work with the installed kernel - right?

I know you guys work hard on fixing stuff and it’s very, very much appreciated! But I think I will wait for the promised updates that are to arrive “soon” (whatever that may be).

I don’t mind to change some files here and there, but now, everything you touch, breaks something else; or then maybe I want the impossible: a working Alexa with an own wakeword, own sounds and working lights…

1 Like

@OPK I got Kitt_ai working just now!

I used the Alexa SDK but I had to make some changes because does not work straightforward. I will make a post tomorrow with the steps. Sorry for the waiting :slight_smile:

-Yoel

@yoelrc88
Yoel, wow that is great news! Im curious to see which steps I missed. Im looking forward to your description to get going this weekend :+1:

@OPK, I push 2 commits to https://github.com/matrix-io/avs-device-sdk/tree/yc/kitt_ai with the necessary changes to make snowboy work with this guide for Alexa. Note that there is a faster guide version that uses a pre-built image.

I will make a nicer guide for this but wanted to share it here first.

Let me know how it goes and if you need any help with it.

-Yoel

@yoelrc88 Good stuff - thanks!!

I did a new build (so not an install from scratch - yet) an all worked well, except:

  1. No lights on the led ring
  2. No sounds (“ding” and “dong”)
    It that an easy fix?

And what outputs are now available with all these changes? Also the speaker outputs on the Voice board e.g?

New build failed on:
sudo apt install matrixio-creator-init
error:
Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
matrixio-creator-init : Depends: libmatrixio-creator-hal but it is not going to be installed
Depends: matrixio-xc3sprog but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

hmm also the sd card image does not install at all - etcher wont burn it - dd doesnt work - it doesnt have any boot information…

make command for kernel modules doesnt work - but installing them by apt-get install matrixio-kernel-modules does work - guide needs updating

ok alexa is kind of working - she gives me the wrong time and any answer longer than 15 seconds gets cut off - any ideas ?? oh and she isnt using analog audio but going through hdmi output (no issue as long as plugged in to monitor )

Weird - I did after the reboot again:
“curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt-key add -”
“echo “deb https://apt.matrix.one/raspbian $(lsb_release -sc) main” | sudo tee /etc/apt/sources.list.d/matrixlabs.list”
and then
“sudo apt install matrixio-creator-init”
works
huh?

@yoelrc88 buildin kitt_ai with your script changes results in:

ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
2018-04-10 19:23:31.836 [  1] I SensoryKeywordDetector:License expires on 28 Jul 2018 00:00:00 GMT
2018-04-10 19:23:31.836 [  1] I SensoryKeywordDetector:Sensory library license does not expire for at least 60 more days.
2018-04-10 19:23:31.837 [  1] E SensoryKeywordDetector:initFailed:reason=loadingSensoryModelFailed,error=snsrLoad()\: task\: No such file or directory (open "...-avs-sample-app/spot-alexa-rpi-31000.snsr")
2018-04-10 19:23:31.837 [  1] E SensoryKeywordDetector:createFailed:reason=initDetectorFailed
Failed to create SensoryKeyWordDetector!
2018-04-10 19:23:31.838 [  1] 0 DefaultClient:DirectiveSequencerShutdown

Would be good to have a clean script :slight_smile:

CMakeFiles/Makefile2:8100: recipe for target ‘SampleApp/src/CMakeFiles/SampleApp.dir/rule’ failed
make[1]: *** [SampleApp/src/CMakeFiles/SampleApp.dir/rule] Error 2
Makefile:2084: recipe for target ‘SampleApp’ failed
make: *** [SampleApp] Error 2