Mycroft Community Forum

PiCroft issue with pairing

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

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.

1 Like

TY!!!

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

thanks a lot!
Ale

1 Like

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

1 Like

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.

2 Likes

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.

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

1 Like

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.

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?

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.

Ah, then you should probably edit /etc/mycroft/mycroft.conf like this.
or copy this in .mycroft/mycroft.conf

(just get rid of the -Dhw:0,0 in aplay!)

{
“play_wav_cmdline”: “aplay %1”,
“enclosure”: {
“platform”: “picroft”,
“update”: true,
“test”: false
},
“play_wav_cmdline”: “aplay %1”,
“play_mp3_cmdline”: “mpg123 %1”,
“tts”: {
“module”: “mimic”,
“mimic”: {
“voice”: “ap”,
“path”: “/usr/local/bin/mimic”
}
}
}

2 Likes

ok tjoen!

with the correct /etc/mycroft/mycroft.conf

the errors at startup are gone!

dditional commands you can use from the command line:
mycroft-cli-client - command line client, useful for debugging
msm - Mycroft Skills Manager, install new Skills from Github
say_to_mycroft - one-shot commands from the command line
speak - say something to the user
test_microphone - record and playback to test your microphone


16:52:40.620 - 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
16:52:40.634 - 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
16:52:40.639 - mycroft.configuration.config:load_local:110 - DEBUG - Configuration /etc/mycroft/mycroft.conf loaded
16:52:40.655 - mycroft.configuration.config:load_local:110 - DEBUG - Configuration /home/mycroft/.mycroft/mycroft.conf loaded
16:52:40.674 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
16:52:41.548 - requests.packages.urllib3.connectionpool - DEBUG - https://api.mycroft.ai:443 “GET /v1/device/ef5da3d9-297f-46ec-bf3f-0359438b47d5/setting HTTP/1.1” 200 4
16:52:41.562 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai

$ test_microphone give the same error

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

BUT NOW I can hear my voice!

and if i use

arecord -c2 -r 48000 -f S32_LE -t wav -V stereo -v file_stereo.wav

i can see a strong signal on vumeters

take the time you need, I’ll wait patiently

I’m not sure of all the changes I’ve made, so maybe it’s better to start from something working and stable

thank you
Ale

That did it! Working great now for a full day! Only trouble I seem to be having at the moment is getting the output volume to change. Even when Mycroft tells me that volume is at zero, it’s still blasting away out the AIY speaker. Any attempts to set volume with amixer at the command line also seem fruitless. Any tips for checking if the volume skill is functioning properly?

1 Like

Still testing the new wifi setup I’m afraid. Hope to get it online before christmas…

Tjoen

Hmmm, I am now able to set the volume with command “raise volume” and “lower volume”.
I did have to change the pulseaudio config for that I think…?

This is my setup:

/home/pi/auto_run.sh:

sudo amixer cset numid=3 "0"   # audio out the analog speaker/headphone jack
amixer set Master 50% # set volume to a reasonable level

/etc/asound.conf:

options snd_rpi_googlevoicehat_soundcard index=0

pcm.softvol {
    type softvol
    slave.pcm dmix
    control {
        name Master
        card 0
    }
}

pcm.micboost {
    type route
    slave.pcm dsnoop
    ttable {
        0.0 10.0
        1.1 10.0
    }
}

pcm.!default {
    type asym
    playback.pcm "plug:softvol"
    capture.pcm "plug:micboost"
}

ctl.!default {
    type hw
    card 0
}

/etc/pulse/default.pa:
#uncomment and change module-alsa-sink and module-alsa-source:
load-module module-alsa-sink device=hw:0
load-module module-alsa-source device=hw:0,0

here it is

1 Like

Are you all using the AIY image, or the Picroft image? I’ve been trying to follow the info here, using the Pycroft image, but without luck so far. The configure-driver.sh script isn’t available unless you git checkout voicekit on the AIY repo (as mentioned here: https://github.com/google/aiyprojects-raspbian/issues/378#issuecomment-390433370 ).

I’ve sorted it out. I’m now able to make a new disk image compatible with the Google AIY Kit, from the stock raspbian_Picroft_2018-03-14 image, based on info I gathered from this thread. I am not, however, installing the whole aiyprojects-raspbian toolchain, since that seems to add a lot of setup time and unneeded packages. My setup steps are in a gist here: https://gist.github.com/clebio/5c0d5af3fbd800e9ecf500ccbed096ac

1 Like

Nice work, @calebio!