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

Hi,
./wakeWordAgent -e sensory works fine, but ./wakeWordAgent -e kitt_ai still doesn’t. With Snowboy it is very easy to change the wakeword, and for that kitt_ai is needed.

Output:

INFO:main: Starting Wake Word Agent
INFO:WakeWordAgent: State set to IDLE(2)
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
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
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
INFO:KittAiSnowboyWakeWordEngine: thread started
INFO:WakeWordIPCSocket::mainLoop thread started
INFO:WakeWordIPCSocket: init socket on port:5123
INFO:WakeWordAgent: thread started
INFO:Not connected! Make sure AVS client is running
ALSA lib pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor
ALSA lib pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor
ALSA lib pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor
ALSA lib pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor
ALSA lib pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor
ALSA lib pcm_file.c:358:(snd_pcm_file_write_bytes) write failed: Bad file descriptor
wakeWordAgent: pcm_file.c:397: snd_pcm_file_add_frames: Assertion `file->wbuf_used_bytes < file->wbuf_size_bytes’ failed.
Aborted

Any ideas?

i got it working with the kernel_modules, but hal after that is not working anymore so i had to change the wakeworkagent not to use the everloop anymore, but kitt_ai works with that, eventually the official alexa sample will work out of the box with it.:

1 Like

@OPK,

The Kitt_ai uses portaudio, that is why you should use the kernel modules to access the mics. The problem is that the current MALOS/HAL packages are not compatible with the kernel modules.
The solution, for now, to have both mics and LEDs working in this demo would be to:

This way the LED implementation in the WakeWordAgent.cpp is compatible with the kernel modules.

Please, give it a try and let me know.

Ok, will try from fresh Stretch install tomorrow, Ive been modifying so many files by now … The LED demos worked fine, recording not so much.

Its getting complicated:-)

With other words the new kernel modules which bring Pyaudio / Portaudio support break MALOS Python everloop examples. Is there an analogous solution like the above for HAL?

While installing the kernel module (https://github.com/matrix-io/matrixio-kernel-modules):
“make” fails:
make -C /lib/modules/4.14.21-v7+/build M=/home/pi/matrixio-kernel-modules modules
make[1]: *** /lib/modules/4.14.21-v7+/build: No such file or directory. Stop.
Makefile:17: recipe for target ‘all’ failed
make: *** [all] Error 2

Went back to older kernel, fails also:

dtc -W no-unit_address_vs_reg -@ -I dts -O dtb -o matrixio.dtbo matrixio-overlay.dts
make -C /lib/modules/4.14.18-v7+/build M=/home/pi/matrixio-kernel-modules modules
make[1]: *** /lib/modules/4.14.18-v7+/build: No such file or directory. Stop.
Makefile:17: recipe for target ‘all’ failed
make: *** [all] Error 2

It seems like you have a newer kernel installed than the standard Raspbian kernel. The Makefile uses “uname -r” to find out which version to build against. For this you should have the corresponding header files in /lib/modules/xxx.

If you are using anything other than Raspbian stretch, you may need to adjust the Makefile to point to the correct header.

My outputs on raspbian stretch:

# uname - r
4.9.59-v7+

# dpkg -l | grep raspberrypi-kernel
ii  raspberrypi-kernel                    1.20171029-1                         armhf        Raspberry Pi bootloader
ii  raspberrypi-kernel-headers            1.20171029-1                         armhf        Header files for the Raspberry Pi Linux kernel

Ok, easiest way was to downgrade to 4.9.59
Using https://github.com/Hexxeh/rpi-firmware/commits/ to find the “commit” code
then install it with:

sudo rpi-update a6b3e852ca70f2a12850b4542438583cc3b29788

make and make install now worked

Ah you have used rpi-update, then you could have pulled the current sources with rpi-source, but I would recommend to stay with the current standard kernel, I suppose the developers of the Matrix will also use the official version (apt-version).

Something simple?

Now all demo’s in ~/matrix-creator-hal/build/demos result in:
can’t send spi message

Any ideas? And yes, SPI is enabled in config.txt

As yoelrc881 mentioned above.

The problem is that the kernel drivers are claiming the SPI device for themselves, at least at the moment. They probably want to avoid that too many processes are writing to it in parallel, but they have already adapted the HAL driver for the everloop kernel module in a branch.

As i don’t see such a branch for MALOS i assume we still need to wait until we can have both, i.e. mics with PyAudio / Portaudio support (kernel modules) and MALOS Python everloop examples.

Some kind of estimate would be nice to have. “Soon” to me means within 2 days…

@ loom
That is what I did, with the result I mentioned: “can’t send spi message”.
I will try once more…

@loom & @ yoelrc88

uninstall MALOS/HAL packages

sudo apt-get purge matrixio-malos matrix-creator-init matrix-creator-malos
sudo apt-get purge matrixio-creator-init libmatrixio-creator-hal libmatrixio-creator-hal-dev
sudo apt autoremove

install the kernel module

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 install matrixio-creator-init
sudo apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel git
sudo reboot
rm -rf matrixio-kernel-modules
git clone https://github.com/matrix-io/matrixio-kernel-modules
cd matrixio-kernel-modules
make && make install
Add in /boot/config.txt: dtoverlay=matrixio

Install HAL from source

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

Demo

cd ~/matrix-creator-hal/build/demos
./everloop_demo
Result: “can’t send spi message”

What did I miss?

you forgot to checkout the kernel_space branch:

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

Ah “checkout” - not as in “check-this-out” :wink:
Ok that worked - now must get /etc/asound.conf right… Right?

i removed my /etc/asound.conf

and created:

# /home/pi/.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"
  }
}

Hmm, recording is now ok, also Alexa with pushing a button in the java client, but the everloop demo does not generate an error, but nothing happens. And ./wakeWordAgent -e kitt_ai results in "can’t open device*