Build an open future with us.

Invest in Mycroft and become a community partner.

Picroft - ReSpeaker 2-Mics Pi HAT


#1

Hello there,

I am having problems setting up Picroft (2018-09-11 Stretch Lightning) using the ReSpeaker 2-Mics Pi HAT. I flashed the image and installed the ReSpeaker drivers as described in the Wiki. Now the audio test start-mycroft.sh audiotest works but MyCroft doesn’t react to the wakeword. Is there anything I missed to setup? Anyone got that mic working with the latest Picroft image?

Thx


#2

Hi there @timbz - if the audiotest is working, but the Wake Word is not, it may indicate an error with the Precise Wake Word engine - link.

If you have a look at;

/var/log/mycroft/voice.log

and

/var/log/mycroft/audio.log

are there any Precise-related messages?

If you run the CLI - mycroft-cli-client - does the microphone in the bottom right hand corner constantly move?


#3

Hi,

the mic in the CLI does not move but I cannot find anything in the logs

/var/log/mycroft/voice.log

Summary
12:09:03.170 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:09:03.182 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:09:03.189 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:09:03.196 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
12:09:03.205 - mycroft.identity:_load:44 - DEBUG - Loading identity
12:09:03.228 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:03.862 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/... HTTP/1.1" 200 334
12:09:03.880 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:09:03.886 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:09:03.892 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
12:09:03.900 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:04.578 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../setting HTTP/1.1" 200 3051
12:09:04.595 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:05.282 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../location HTTP/1.1" 200 4
12:09:05.309 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:09:05.314 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
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 pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
12:09:07.063 - mycroft.client.speech.listener:create_wake_word_recognizer:243 - INFO - creating wake word engine
12:09:07.071 - mycroft.client.speech.hotword_factory:load_module:261 - INFO - Loading "hey mycroft" wake word via pocketsphinx
12:09:07.503 - mycroft.client.speech.listener:create_wakeup_recognizer:263 - INFO - creating stand up word engine
12:09:07.508 - mycroft.client.speech.hotword_factory:load_module:261 - INFO - Loading "wake up" wake word via pocketsphinx
12:09:07.664 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:08.277 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/... HTTP/1.1" 304 0
12:09:08.307 - mycroft.messagebus.client.ws:on_open:62 - INFO - Connected
12:09:10.683 - mycroft.client.speech.mic:listen:487 - DEBUG - Waiting for wake word...
12:10:49.557 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:10:49.565 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:10:50.191 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../setting HTTP/1.1" 304 0
12:10:50.209 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:10:50.844 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../location HTTP/1.1" 304 0
12:10:50.888 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:10:50.893 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded

/var/log/mycroft/audio.log

Summary
12:09:03.312 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:09:03.514 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:09:03.711 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:09:03.911 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
12:09:04.103 - mycroft.identity:_load:44 - DEBUG - Loading identity
12:09:04.118 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:04.766 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/... HTTP/1.1" 200 334
12:09:04.972 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:09:05.141 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:09:05.314 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
12:09:05.322 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:05.982 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../setting HTTP/1.1" 200 3051
12:09:05.999 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:06.642 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../location HTTP/1.1" 200 4
12:09:06.887 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:09:07.105 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
12:09:07.524 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:09:08.193 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../subscription HTTP/1.1" 200 114
Carnegie Mellon University, Copyright (c) 1999-2011, all rights reserved
mimic developers, Copyright (c) 2016, all rights reserved
version: mimic-1.2.0.2 ()
12:09:09.278 - __main__:main:38 - INFO - Starting Audio Services
12:09:09.292 - mycroft.messagebus.client.ws:on_open:62 - INFO - Connected
12:09:09.314 - mycroft.audio.audioservice:get_services:58 - INFO - Loading services from /home/pi/mycroft-core/mycroft/audio/services/
12:09:09.343 - mycroft.audio.audioservice:load_services:102 - INFO - Loading chromecast
12:09:26.121 - mycroft.audio.audioservice:load_services:102 - INFO - Loading mopidy
12:09:26.144 - mycroft.audio.audioservice:load_services:102 - INFO - Loading mplayer
12:09:26.267 - mplayer__init__:<module>:20 - ERROR - install py_mplayer with pip install git+https://github.com/JarbasAl/py_mplayer
12:09:26.271 - mycroft.audio.audioservice:load_services:108 - ERROR - Failed to import module mplayer
ImportError("No module named 'py_mplayer'",)
12:09:26.276 - mycroft.audio.audioservice:load_services:102 - INFO - Loading simple
12:09:26.304 - mycroft.audio.audioservice:load_services:102 - INFO - Loading vlc
12:09:26.562 - mycroft.audio.audioservice:load_services:123 - ERROR - Failed to load service. NameError("no function 'libvlc_new'",)
12:09:26.567 - mycroft.audio.audioservice:load_services_callback:170 - INFO - Finding default backend...
12:09:26.571 - mycroft.audio.audioservice:load_services_callback:174 - INFO - Found local
12:10:49.557 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:10:49.567 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:10:50.194 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../setting HTTP/1.1" 304 0
12:10:50.213 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:10:50.831 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../location HTTP/1.1" 304 0
12:10:50.875 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:10:50.884 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded
12:10:50.893 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/mycroft-core/mycroft/configuration/mycroft.conf loaded
12:10:50.900 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:10:51.557 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../setting HTTP/1.1" 304 0
12:10:51.573 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai:443
12:10:53.084 - urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 "GET /v1/device/.../location HTTP/1.1" 304 0
12:10:53.127 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
12:10:53.135 - mycroft.configuration.config:load_local:109 - DEBUG - Configuration /home/pi/.mycroft/mycroft.conf loaded

Thx


#4

Can you alter which microphone is selected using alsamixer?


#5

What do you mean? I can select the mic in alsamixer

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: seeed2micvoicec [seeed-2mic-voicecard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 []
  Subdevices: 0/1
  Subdevice #0: subdevice #0

#6

Wait - can you do this with native alsa? I am also using the Respeaker 2 Mic hat, and was under the impression that PulseAudio was required.


#7

Well, the picroft image does not use pulseaudio and the Google AIY seems to work with alsa.


#8

Ah - I followed this guide to install it: https://www.j1nx.nl/diy/diy-home-personal-ai-assistant-installing-configuration-part-4/ - which mentioned pulseaudio, but I’ll admit, if there is a less complicated route to output with Alsa I’d jump at it.

What is in your /etc/mycroft/mycroft.conf?
I’m going to try resetting mine to not use pulseaudio - simpler is better.


#9
$ cat /etc/mycroft/mycroft.conf
{
"play_wav_cmdline": "aplay %1",
"play_mp3_cmdline": "mpg123 %1",
"enclosure": {
    "platform": "picroft"
},
"tts": {
    "mimic": {
        "path": "/home/pi/mycroft-core/mimic/bin/mimic"
    }
},
"ipc_path": "/ramdisk/mycroft/ipc/"
}

I am also trying to avoid pulse audio


#10

I’m seeing if I can setup /etc/asound.conf - perhaps I can select defaults there that will help…


#11

Ok I have wakewords working, and the mpg123 config works - but it’s not speaking to me.

/etc/asound.cnf:

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw           
    card 1
}

It will sing me a song, but not speak to me yet. I did have hw:1 in the mycroft.conf settings - so I’m trying to reboot without those in there.


#12

Did you use the Picroft 2018-09-11 Stretch Lightning image?


#13

Curently I built my own on stretch using https://github.com/MycroftAI/enclosure-picroft/blob/stretch/image_recipe.md#install-picroft-scripts, however, that is worth a try.


#14

Yeah, I wrote that piece of information when the new lightning release was not yet available and based on the information at hand by that time, pulseaudio was a requirement in all the info snippets here and there.

I will investigate if pulseaudio is “really needed” or an alsa only setup could be done aswell.

However, for the moment I stepped away from raspbian and focussed on buildroot instead.

As soon as I am at the sound stuff within that project, I will investigate it more. Keep this thread under my bookmarks for now.


#15

Ok - tried the lightening image. I did an update and ran the seeed guide.
I had to take out the hw:0,0 references from /etc/mycroft/mycroft.conf.
I added a small section to asound.conf:

ctl.!default {
  type hw
  card 1
}

This is how I set up alsamixer to consider it the default mixer.
The mpg123 output is working, but the main output does nothing (even if I type the say skill).
I also don’t see a mic level.
Digging more.


#16

Digging has lead me to https://github.com/MycroftAI/mycroft-core/blob/dev/mycroft/client/speech/listener.py, which creates an intance of a Mutable Mic, a superclass of the Microphone from https://github.com/Uberi/speech_recognition/blob/master/speech_recognition/init.py. My thinking is that it’s the device_index perhaps.

Listener.py uses config to get a “device_index” config. So I’ll try to find what config has for defaults for that.


#17

No defaults - but this might work (since hte card index is 1) in /etc/mycroft/mycroft.conf:

  "listener": {
     "device_index": 1
   },

Which is also the place to mess with wake words too…
Nope - still no mic levels or waking.


#18

Well thats annoying. I added debug into client/speech/mic.py to log the parameters to the MutableMic, restarted mycroft, and then it seemed to work.
The only other thing I did, was cat the /ramdisk/mycroft/ipc/mic_level file to see what was in it… It was static until I stopped mycroft and started it again. I’m going to check what happens at a reboot. In case the problem is at start up.

Hmm - no dice on startup…
Try stopping and starting mycroft…
And it works - something about the way it is starting - perhaps a race condition in the parts that run?

So after a reboot, the processes seem to be there, but there is one write to the mic_level file during startup and no further writes. I used debug, and it seems to get a few reads, then stall in self.pyaudio_stream.read(size, exception_on_overflow=False) (called from MutableMicrophone, passed into the mic listen loop, found in the wait_until_wake_word method). Guess the next question is why that stream stalls, and then seems to be okay on a restart of mycroft (but not a reboot).

It’s not timing - sleeps dont help (the auto_run.sh has them anyway). I was comparing the env of my putty terminal with the console that auto run first starts the mycroft services, and didn’t find anything specific there. I have checked if there was a difference between source mycroft-core/start-mycroft.sh all and ./mycroft-core/start-mycroft.sh all but not seen a change in this behavior - it still only starts the second time.
I may try to log in with a screen and keyboard attached (which should put me at the console it’s started in I think), and see if a second run works or fails there, is my headless start making a difference? Nope - still loads with mic levels on the second time.


#19

You can add /etc/modprobe.d/alsa_base.conf with:

# This sets the index value of the cards but doesn't reorder.
options snd_soc_simple_card index=0   
options snd_bcm2835 index=1

# Does the reordering.
options snd slots=snd_soc_simple_card,snd_bcm2835 

to change the sound card order