Mic doesn't work on startup - only after running mycroft-mic-test

My Picroft doesn’t recognize the wake word on startup, nor after restarting the mycroft-cli-client. Audio outputs over HDMI if I type in a command (“what time is it”). However, if I run mycroft-mic-test, I can hear the test noise fine, and relaunching mycroft-cli-client I can now see the mic level meter, and it responds correctly to the wake word.

Installation details:

I was unable to connect my Picroft (3B+) to the internet from the picroft image (the enclosure-picroft one linked on github - sorry, new users can’t post many links) (I tried from mycroft-setup-wizard, in hindsight I should have tried raspi-config as well), so I followed the instructions and used the lastest raspbian lite stretch and update.sh as described here. I am using a seeed 2-mic respeaker pihat and installed the drivers as per here.

  1. Any idea what the mic-test is doing?
  2. I actually want audio output via the respeaker card too - how can I change that?
  3. The update.sh script didn’t appear to install pulseaudio. Should it have?

Thanks for any help!

System info:

Audio.log ERRORs {no errors in the other logs):

    09:22:32.485 - mplayer__init__:<module>:20 - ERROR - install py_mplayer with pip install git+https://github.com/JarbasAl/py_mplayer
    09:22:32.490 - mycroft.audio.audioservice:load_services:108 - ERROR - Failed to import module mplayer
    09:22:32.638 - mycroft.audio.audioservice:load_services:123 - ERROR - Failed to load service. NameError("no function 'libvlc_new'",)
    09:27:21.497 - mplayer__init__:<module>:20 - ERROR - install py_mplayer with pip install git+https://github.com/JarbasAl/py_mplayer
    09:27:21.502 - mycroft.audio.audioservice:load_services:108 - ERROR - Failed to import module mplayer
    09:27:21.798 - mycroft.audio.audioservice:load_services:123 - ERROR - Failed to load service. NameError("no function 'libvlc_new'",)

Config:

    pi@picroft:~ $ cat /etc/mycroft/mycroft.conf 
    {
       "play_wav_cmdline": "aplay -Dhw:0,0 %1",
       "play_mp3_cmdline": "mpg123 -a hw:0,0 %1",
       "enclosure": {
          "platform": "picroft"
       },
       "tts": {
          "mimic": {
             "path": "/home/pi/mycroft-core/mimic/bin/mimic"
          }
       },
       "ipc_path": "/ramdisk/mycroft/ipc/"
    }
    pi@picroft:~ $ cat .mycroft/mycroft.conf 
    { "max_allowed_core_version": 18.8 }

Audio card:

    pi@picroft:~ $ aplay -L
    null
        Discard all samples (playback) or generate zero samples (capture)
    default
    playback
    capture
    dmixed
    array
    sysdefault:CARD=ALSA
        bcm2835 ALSA, bcm2835 ALSA
        Default Audio Device
    dmix:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Direct sample mixing device
    dmix:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Direct sample mixing device
    dsnoop:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Direct sample snooping device
    dsnoop:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Direct sample snooping device
    hw:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Direct hardware device without any conversions
    hw:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Direct hardware device without any conversions
    plughw:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Hardware device with all software conversions
    plughw:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Hardware device with all software conversions
    sysdefault:CARD=seeed2micvoicec
        seeed-2mic-voicecard, 
        Default Audio Device
    dmix:CARD=seeed2micvoicec,DEV=0
        seeed-2mic-voicecard, 
        Direct sample mixing device
    dsnoop:CARD=seeed2micvoicec,DEV=0
        seeed-2mic-voicecard, 
        Direct sample snooping device
    hw:CARD=seeed2micvoicec,DEV=0
        seeed-2mic-voicecard, 
        Direct hardware device without any conversions
    plughw:CARD=seeed2micvoicec,DEV=0
        seeed-2mic-voicecard, 
        Hardware device with all software conversions

OK, I’ve figured out how to get audio to work properly:

First I edited /etc/mycroft/mycroft.conf:

   "play_wav_cmdline": "aplay -Dhw:1 %1",
   "play_mp3_cmdline": "mpg123 -a hw:1 %1",
   "enclosure": {
      "platform": "picroft"
   },
   "tts": {
      "mimic": {
         "path": "/home/pi/mycroft-core/mimic/bin/mimic"
      }
   },
   "ipc_path": "/ramdisk/mycroft/ipc/"

For some reason thing fixed the “sing me a song” skill, but not regular talking. Then I followed the instructions from the ALSA Project here to add these lines to /etc/asound.conf set my default sound card:

defaults.pcm.card 1
defaults.ctl.card 1

That has fixed my audio output by setting the default soundcard system-wide, which is fine for my purposes, but I wonder if there’s a way to set it just for Mycroft?

I am still having the issue where I need to run mycroft-mic-test before the Picroft starts listening for my voice.

I believe you can set some of this in the .asoundrc file:
https://www.alsa-project.org/main/index.php/Asoundrc

The command I need to get the mic working is this:

(.venv) pi@picroft:~ $ /home/pi/mycroft-core/start-mycroft.sh voice
Initializing...
Restarting: voice
Stopping speech...stopped.
(.venv) pi@picroft:~ $ 

From what I can tell reading the script, the Restarting: voice line implies that the service was already running. But the mic doesn’t work until restarting the service. I’m afraid I don’t have a USB mic to test if this is a problem with my soundcard or something more general.

I am havin the same issue or a one close to your issue.

I use a rpi-3b+ with picroft stable (doing raspi update+raspbian-upgrade) and install the git fpr my 4-mic-respeaker modul, like mentioned here.

After that I start alsamixer and choose as default mic the new seeed-4-array-mic. See here.

Now Mycroft is hearing me but only when I do some inputs. Then he can his keyword but after some test he did not listening anymore.

I dont know what to do know… :frowning:

Any idea?