PiCroft issue with pairing


#1

Hi,
I am installing PiCroft in Rpi 3. I have a 2.5A power supply. It does have Google VoiceHat installed.

I am able to get it working. It did recognize the wake word and also the request to “pair my device”.

But i get following error:

20:08:39.127 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 “GET /v1/auth/token HTTP/1.1” 401 38
20:08:39.140 - mycroft.client.speech.listener:transcribe:153 - WARNING - Access Denied at mycroft.ai

What am I doing wrong?


Mycroft with Google AIY Voice kit disk image
Mycroft with Google AIY Voice kit disk image
PiCroft and AIY Voice kit
Mycroft on AIY Voice kit
#2

I am having a Googlevoicehat as well, and did pair using the CLI. But I am not able to get voicehat to work…How did you do that? Any guidance link or something ?

If I get voicehat working I can tell you if I also get same error :slight_smile:


#3

If you have the AIY google image, look into the /scripts directory.

It has 3 files you need

  1. asound.conf
  2. configure-drive.sh
    3 . install-alsa-config.sh

Run, the following code:

./configure-drive.sh
./install-alsa-config.sh

Now your RPi should be able to recognize VoiceHat. Test it by the following.

aplay -l
aplay -L
It should show the sound card as googlexxxx.

aplay /usr/share/sounds/alsa/Front_Left.wav
Should play the file and you should be able to hear it via the speaker.

I have latest mycroft image installed with the above drivers.

~/bin/test_microphone
should record your voice. Even if you do not hear anything from the speaker, it does tell you a file it creates of the recording.

That file is usually /tmp/test.wav. Play that you will be able to make sure your microphone works.

For all the magic to happen, pulseaudio needs to work properly.

Good luck.


#4

I did:
Insall picroft.
Boot up
git clone https://github.com/google/aiyprojects-raspbian.git
cd aiyprojects-rasbian/scripts
./configure-driver.sh
./install-alsa-config.sh
sudo systemctl reboot -i

Evrerything seems to work testing whith CLI client not seeing same errir as you.

But I dont have audio, and no wakeword working…

So to get the magic to happen i’ll gues pulseaudio needs to work properly. Any clues how to config this?


#5

Got it working - or nearly working.

Updated kernel.

I did:
sudo apt-get update
sudo apt-get install raspberrypi-kernel
git clone https://github.com/google/aiyprojects-raspbian.git
cd aiyprojects-rasbian/scripts
sudo scripts/configure-driver.sh
sudo scripts/install-alsa-config.sh
sudo systemctl reboot -i

Now it listen, and get wakeword and question. But still no sound.


#6

Goto ~/bin
and run the following

./speak “Can you hear me now”

let me know, if you hear anything.

I did a clean install again. I got it to pair using mycroft_speech_client.
I can hear “mimic” but not mycroft.
When it records via microphone, the volume is too low for me.


#7

I actually did the same as you guys, but also changed something in default.pa

sudo vi /etc/pulse/default.pa
uncomment and change:
load-module module-alsa-sink device="hw:0"
load-module module-alsa-source device=“hw:0,0”

That seems to work, and also fixes the flat volume speaker output.

I also got some button and led code working, mostly stolen from google examples:

Needs work, but it works.


#8

Hi I followed your instructions (a merge)

Install picroft 0.9 on RPI3+AIY
Boot up
sudo apt-get update
sudo apt-get install raspberrypi-kernel
git clone https://github.com/google/aiyprojects-raspbian.git
cd aiyprojects-rasbian/scripts
sudo scripts/configure-driver.sh
sudo scripts/install-alsa-config.sh
sudo systemctl reboot -i

then

sudo vi /etc/pulse/default.pa
uncomment and change:
load-module module-alsa-sink device="hw:0"
load-module module-alsa-source device=“hw:0,0”

Now i have the sound but not listen… so I paired mycroft via CLI

Could you give me some tips to correct the problem?


USB Mic Won't Work (Used To)
#9

Sure, check if arecord -l is seeing the voicehat

should say:**** List of CAPTURE Hardware Devices ****
card 0: sndrpigooglevoi [snd_rpi_googlevoicehat_soundcar], device 0: Google voiceHAT SoundCard HiFi voicehat-hifi-0 []
Subdevices: 0/1
Subdevice #0: subdevice #0

if that is ok. Run amixer -d

Simple mixer control ‘Master’,0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 49345 [75%] [on]
Front Right: Playback 49345 [75%] [on]
Simple mixer control ‘Capture’,0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 65536
Front Left: Capture 49152 [75%] [on]
Front Right: Capture 49152 [75%] [on]

Last 2 lines are the mics, are they on?


#10

Oh, also edit /etc/modules and add:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev

The mics are using i2c

You could also enable it through raspi-config I think.

I updated the kernel like this:
#Update kernel version to 4.9
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install rpi-update
sudo rpi-update
sudo reboot

But if your sound is working, it should use the right kernel already


Mycroft with Google AIY Voice kit disk image
#11

Hi tjoen!
I followed your instructions, at the command arecord -l I got your same output

In the command amixer -d i got only Volume:

$ amixer -d
Simple mixer control ' Master ', 0
Capabilities: Volume
Playback channels: Front Left-Front Right
Capture channels: Front Left-Front Right
Limits: 0-255
Front Left: 216 [85%]
Front Right: 216 [85%]

So I edited modules and inserted I2C-dev
I installed rpiupdate and updated the kernel from 4.9.35 to 4.9.64 and reboot…

But I still don’t see the microphones with amixer -d

Do I need other changes in/boot/config.txt ?

Currently the section is :

# uncomment some or all of these to enable the optional hardware interfaces
#dtparam = i2c_arm = on
dtparam = i2s = on

and I can’t detect the i2c microphone

sudo i2cdetect -y 1
Error: Could not open file /dev/i2c-1' or/dev/i2c/1’: No such file or directory


#12

my /boot/config end like this:

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
dtoverlay=i2s-mmap
dtoverlay=googlevoicehat-soundcard

What happens if you try to stop the service
sudo service mycroft-speech-client stop

Wait a couple of seconds, and see if this works:
arecord -D hw:0,0 -c2 -r 48000 -f S32_LE -t wav -V stereo -v file_stereo.wav

It should record from your mics.


#13

TY!!!

perfect! I modified the boot/config.txt and now it working!
I see the left and right mic vumeters

thanks a lot!
Ale


#14

Great!

I just updated my button / lights code. Check this gist,
I updated it to the latest version
It listens to the messagebus and works pretty good in my tests today.

button code


#15

So just to clarify, what ultimately fixed the audio Input/Output with the VoiceHat for others? I have mine working now, just curious to hear what the final solution others used was.

I would avoid editing the default pulseaudio config in this way

I spent a good hour viewing and editing any relevant config files on the file system, to find that I hadn’t even checked that the pulseaudio daemon was still running. This, unfortunately, is what I tend to experience at 2AM with no caffeine. Additionally, if anybody is still having trouble with this, the steps I took were:

Additionally, I also replaced the section beginning in pcm.!default in /etc/asound.conf with this:

pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm “hw:0,0”
}
capture.pcm {
type plug
slave.pcm “hw:0,0”
}
}

Thanks for the button code tjoen, I’ll definitely take a look at that and either use it or make my own, as I’m using this more as a kit for learning to develop applications that can be controlled by smart home assistants, as apposed to expecting a polished product that just works. Thought this was a good place to start due to the hackability of mycroft. This thread was really helpful, thank you all.


#16

I would avoid editing the default pulseaudio config in this way

You are probably right, but I kept loosing the alsa-sink for some reason, Maybe I should change the asound,conf like you did, although I don’t get what device hw:1,0 is?

is that your internal soundcard?

T.


#17

You’re totally correct. I think I’d edited the file after I got it working to copy this and accidentally changed the value. Sorry! I was tired. I’ve edited my config file to remove my mistake and edited my summary post. Now everything is working just fine for me.

Crumpy


#18

So I think I’m very close, but that asound.conf file in the most recent post wasn’t working for me. I’m getting errors on both aplay -l and arecord -l.

pi@picroft:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
ALSA lib conf.c:1697:(snd_config_load1) toplevel:33:2:Unexpected char
ALSA lib conf.c:3417:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3339:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration
aplay: device_list:277: control open (0): Invalid argument
pi@picroft:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
ALSA lib conf.c:1697:(snd_config_load1) toplevel:33:2:Unexpected char
ALSA lib conf.c:3417:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3339:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3788:(snd_config_update_r) hooks failed, removing configuration
arecord: device_list:277: control open (0): Invalid argument

When I modify slightly to

pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm “hw:0”
}
capture.pcm {
type plug
slave.pcm “hw:0”
}
}

Then it seems to work, and I can confirm my speech is recognized in mycroft-cli-client and I can see microphone vu meters, but I get no audible reply, despite text in the cli. I also can confirm my speaker is working by using the “speak” command.


#19

ok I’m lost!

I tried to edit ./etc/asound.conf in order to get a boost on the microphone because otherwise it was working but too low to start the speech recognition

I followed this post: https://github.com/google/aiyprojects-raspbian/issues/94

but now i have new problems…
speak “can you heard me” works well
amixer -d now shows the capture channels and their amplification level

Simple mixer control ‘Master’, 0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 255
Front Left: 147 [58%]
Front Right: 147 [58%]
Simple mixer control ‘Boost’, 0
Capabilities: cvelume
Capture channels: Front Left - Front Right
Limits: Capture 0 - 255
Front Left: Capture 226 [89%] [27.12dB]
Front Right: Capture 226 [89%] [27.12dB]

but now when picroft start I get these errors:

ALSA lib pulse.c: 243: (pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pcm_dmix.c: 961: (snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c: 557: (snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream

and if I try a microphones test, I get this printout:
> pi @ picroft: ~ $ ~ / bin / test_microphone
> Shutting down mycroft …
**> Starting a 5 second test recording **
> ===========================================================
> == STARTING TO RECORD, MAKE SOME NOISE! ==
> ===========================================================

ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
… bla bla
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

> ALSA lib pcm_dmix.c:961:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
> ALSA lib pcm_dsnoop.c:557:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
> ===========================================================
> == DONE RECORDING, PLAYING BACK… ==

===========================================================
13:25:46.901 - mycroft.configuration.config:load_local:110 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.10-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:25:46.909 - mycroft.configuration.config:load_local:110 - DEBUG - Configuration /usr/local/lib/python2.7/site-packages/mycroft_core-0.9.10-py2.7.egg/mycroft/configuration/mycroft.conf loaded
13:25:46.913 - mycroft.configuration.config:load_local:110 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:25:46.917 - mycroft.configuration.config:load_local:115 - DEBUG - Configuration ‘/home/pi/.mycroft/mycroft.conf’ not found
13:25:46.927 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:25:47.507 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 “GET /v1/device//setting HTTP/1.1” 401 38
13:25:47.521 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
13:25:48.101 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 “GET /v1/auth/token HTTP/1.1” 401 38
13:25:48.123 - mycroft.configuration.config:init:157 - ERROR - HTTPError fetching remote configuration: 401
13:25:48.126 - mycroft.configuration.config:load_local:115 - DEBUG - Configuration ‘/opt/mycroft/web_config_cache.json’ not found
13:25:48.130 - mycroft.configuration.config:load_local:110 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
13:25:48.134 - mycroft.configuration.config:load_local:115 - DEBUG - Configuration ‘/home/pi/.mycroft/mycroft.conf’ not found
Playing back the recording…
Playing WAVE ‘/tmp/test.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
aplay: set_params:1233: Sample format non available
Available formats:

  • S32_LE
    Restarting mycroft…

which is the right version of /etc/asound.conf to get mic boost and right output?


#20

I used the /etc/asound.conf that has been created by the google script.
I could also not get the asound,conf to work with my setup.

I have created a diskimage of the working 0.9.10 setup. Should update ok too.
Been using it for the last 3 versions.

Sorting out some problem with the wifi setup in the new 0.9.10 version.
But it should be online tonight or tomorrow hopefully.

I’ll post it in this thread later, have to upload it to google drive first. It has some advanced features, like backup to ntfs usb-drive and pishrink, sonos and chromecast streaming, working button code, and some skills we’ve developed.