It’s Alive!

In late 2016 I created the original Picroft as a way for anyone to interact with Mycroft, not just those who were able to purchase the Mark 1. Since then, Picroft has been downloaded more than 35,000 times. It has become the basis for numerous Raspberry Pi projects, like Magic Mirrors, home automation systems, robots, and hundreds of other wonderful testaments to creativity.

Picroft was designed to self-update, and we did publish some new versions periodically to simplify moving to major new releases. It has held up well and essentially remained the same for the last two years.

However, the new Raspberry Pi 3B+ introduced new chipsets that broke Picroft. The original Pi 3 is still available, but this was a good reason to show Picroft some love and introduce some cool new stuff.

[caption id=“attachment_40527” align=“alignnone” width=“1316”] This was the sky the night I started rebuilding the Picroft image. Fitting, right?[/caption]

What’s New?

Lots of little things, and a few big things. Once things are up and running, it will still be Mycroft -- a voice interface. The main changes are at the setup and “plumbing” level. We also listened to the findings of our Picroft survey -- thanks to all who participated!

Stretch’ing ourselves

With the release of the Raspberry Pi 3B+ hardware changes required a new release of the Raspbian operating system. The new version is referred to as “Stretch” (following the tradition of Toy Story references). Picroft is now based on this latest version of Raspbian, allowing support for both the Raspberry Pi 3 and the 3B+.

No more packages, go Git it

To simplify and unify the Mycroft experience on the various platforms, we rethought how Mycroft should sit on the Raspberry Pi. At the low level, we switched from a Debian package install (which was originally a hack of the Mark 1 package that just disabled the faceplate) to a Github-based install that can be set to automatically update.

This unifies the Picroft environment with what most desktop developers are using, allowing us to simplify documentation.

Wizards!

One of the recurring issues users encounter is difficulty in configuring the audio pieces. Linux is incredibly flexible, but nobody wants to deal with the audio subsystems if they can avoid it. Configuring sound drivers is full of alchemy and dark magic. Connecting to all the different kinds of wifi security protocols is a whole different book of incantations. So we are including a Wizard with Picroft to help cast these spells!

During the initial setup, the user is now presented with a series of simple questions to configure the network connection, pick the type of microphone and audio output they want to use, and configure security options based on their intended use. Configuration happens automatically, and tests immediately verify the speaker output and sound levels, and the microphone input.

MOAR Microphones

We have a great community who have proven that Mycroft can operate with nearly any kind of hardware. Over the next few days, the Picroft image will incorporate support for the Google AIY Voice Kit array microphone. In the future, there will be an easy path for automating the install of other microphones, such as the Matrix Creator and Seeed ReSpeaker.

Environment Helpers

As I developer, I feel justified in making fun of every time one of us answers a question by saying something like:

Oh, that is really simple. First pip install pyjokes. Then just type python -m test.integrationstests.skills.runner. You are in the virtual environment, right? Oh, well you just need to do source /opt/venvs/mycroft-core/bin/activate before that. Still not working? Oh, were you in the venv when you did the pip install? …

I’ll let you in on a secret – this is also a pain for us and we probably mistype these commands half the time.

As part of this overhaul, we’ve unified most Mycroft related commands under a mycroft- prefix. This is particularly helpful because you can now take advantage of Linux’s excellent auto-completion by typing my<TAB> to get to mycroft-, then hit TAB two more times to see all the options available for you.

Helpers include:

mycroft-helpGet brief summaries of the commands

mycroft-pipInstall Python packages inside the Mycroft venv

mycroft-msmInvoke the Mycroft Skills Manager

mycroft-mskMycroft Skill Kit, submit and manage skills in the community repos

mycroft-speakMake mycroft speak for you (handy inside scripts)

mycroft-say-toSend a string to Mycroft, just like you spoke it (also handy for scripts)

These same tools are also available under all other environments now.

What Else Can You Look Forward To?

We’ll be providing Skills that are unique to the Picroft environment, allowing you to attach buttons to the GPIO pins to emulate the Mark 1 button. Or use this example to do whatever else you might want to do -- this is your Picroft!

As mentioned above, we’d like to expand the microphone and audio hardware supported by Picroft. With a little help from community members, I expect we’ll have support for various USB and Bluetooth mics and speakers soon. Join us on the forums to give feedback on AIY integration, how to pipe in new mics, and what you’d like to connect over GPIO.

I’m look for feedback on how this image is working for you – I only have a few mics myself!

I know the AIY setup isn’t up to snuff yet, but decided to push this since AIY wasn’t supported by the previous stable image, and this is definitely an improvement when using the supported mics. I could use help from anyone who can assist in getting AIY, Matrix, Respeaker or any other non-standard mics running. Same for Bluetooth speakers (I’m not sure if anyone has that working well yet).

P.S. This article got pushed before I had updated the picroft-image link. So if you downloaded the image before this message, you probably need to re-download it. The new image shows ASCII-art “Mycroft” and “Picroft” at boot, so it is easy to distinguish.

@steve.penrod thanks for creating the picroft images and updating to Stretch. They make setting up a picroft really simple thanks!

Do you have a checksum for the raspbian-stretch_Picroft_2018-09-12.zip? I could only find them for the previous releases on the enclosure-picroft github. I’ve already had a failed download attempt (stopped at 2.097 GB) so would like to check the image when I manage to get it to download fully.

I’m hoping to get a bluetooth speaker/mic to connect to this new version. I couldn’t get raspbian_Picroft_2018-03-14.zip (which I normally used with a PS Eye and analogue speakers) to find any bluetooth devices (the scan kept timing out no matter what trickery I tried to apply from the web). I have another Stretch rpi (a reropie) which connects to bluetooth without any hassle so I hope to compare them like-for-like if I run into any problems.

EDIT: I found the checksum on the enclosure-picroft github. Not sure how I missed it earlier sorry. (failed to download twice now )

AIY v.1. Pi 3B+ 3A m-c 18.8.1
On the AIY option (3) it pulls lots of stuff in, looking similar to the google assistant version. The speaker comes up in a google voice model, but nope, no microphone. Best of luck with this part. The button light/function, is not triggering either. I’ve tried a variety of fresh installs, with a Samson USB mic as well, but not so much. That one throws errors.

To make the last connect audio device be the active one type pactl load-module module-switch-on-connect (this module can be added to /etc/pulse/default.pa so that it is automatically loaded)

I initially thought the file /etc/bluetooth/audio.conf had to be created with the following contents but it still worked for me after I removed the file.

[General]
Enable=Source,Sink,Headset,Gateway,Control,Media,Socket

Pair/trust/connect bluetooth speaker:

Type bluetoothctl

Put bluetooth speaker in pairing mode and type scan on.

When the mac address (<mac>) of the speaker is found type:

pair <mac>

trust <mac>

connect <mac>

exit

Sound should now come from the bluetooth speaker. This is where it gets more complicated. There are two main profiles a speaker can have: a2dp_sink and headset_head_unit. a2dp_sink provides high fidelity stereo playback (speaker only) with a sample rate of around 44 kHz whereas headset_head_unit provides bidirectional mono audio (ie. both microphone and speaker which are referred to as source and sink, respectively) with a sample rate of only 8 kHz each. The available cards and their profiles can be viewed with the command pactl list cards | grep -edescrip -eHSP -eA2DP -eActive -eCard and set with the command pactl set-card-profile <card> <profile>.

The headset_head_unit profile is split into two sub-profiles: headset profile (HSP) and hands-free profile (HFP). With pulseaudio 10 HSP is natively supported but for HFP ofono must be installed. The features available for the connected bluetooth device can be found with the command info <mac> executed within bluetoothctl.

Here arises the problem I have been contending with: the available features of the device are not always seen as available by pactl. For some devices the combination of a2dp_sink and headset_head_unit availability is random and for others the availability is dependant on whether the device was connected automatically or manually with bluetoothctl. A profile can only be set when pactl thinks it’s available. When a device is reconnected and the profile it was previously connected with is not available it will be set to off and must be manually set to an available profile.

I have two bluetooth devices I’ve been testing with: a headset (Philips SHB7000) and a speaker (Sephia A2). The available profiles for the headset are random but when they both show as available both profiles work fine. The speaker however always has a2dp_sink and only has headset_head_unit when it’s connected manually. When I finally found the “manual connection” trick to set the speaker profile as headset_head_unit I thought I finally found how to get the speaker’s microphone working. Unfortunately this was not the case and when I use the speaker in the headset_head_unit profile I get nothing from the speaker or microphone - I can only hear the background hum on the speaker. I have not found a solution to this so even if the headset_head_unit profile is available it might not work. In my opinion, not being able to use the microphone drastically reduces the usefulness of using a bluetooth speaker with Mycroft.

A separate issue is that when headset_head_unit does work it sounds absolutely terrible! This is not due to the low sample rate but cause by a bad bit of code in pulseaudio 10. It has been fixed in later versions but for it to work with picroft I had to patch version 10 as described here. This produced libbluez5-util.so which can replace the original in /usr/lib/pulse-10.0/modules/. With this patch the audio sounds as it should with a sample rate of 8 kHz and mycroft can then recognise commands. It works for both rpi3b and rpi3b+ models.

I focussed more on HSP rather than HFP in my research because the added dependency of ofono for HFP seemed to add yet another layer of complexity and because the most recent version of pusleaudio concentrates more on HSP. I may try to look more into HFP to see if it’s any better or reliable.

Thanks for that detailed analysis! I’ve suspected the Bluetooth solution isn’t likely ready for prime-time – the speaker side is pretty well defined but the Mic side is still messy. Android phones are still finicky, and I’m sure they have hundreds of hard-coded cases built in there.

Part of the new Picroft approach is to provide very specific menu options for hardware that we know works, then making that hardware super easy to install. This makes it obvious that trying that $2 usb mic you pulled out of the drawer may not work but there is a $7 option that is guaranteed to work. Users can then decide if their time is worth the $7 – and if it is I hope they share the details and so we can add the new mic to the the “supported” list.

Until I see a scriptable and repeatable process for a specific Bluetooth speaker, I will consider this a wish-list item. I’m happy to help with making the script seamless, but I’m going to leave the time consuming research side in capable hands such as yourself! As you get close to a solution, start a PR and we can get it in.

I copied and pasted Andlo’s script to get AIY working onto the 9/12 image and have not been able to get MyCroft working on my Pi 3 B+. The error messages are:
“sed: couldn’t open temporary file /boot/sedHUUDo6: Permission denied” (So I manually changed config.txt.)

Hi guys, I got a question.
I have a google AIY kit with Raspberry pi 3. I’m using this new picroft image and I have problems with sound. On the image it does not give options to use Google VoiceHAT (v1) as your speaker.

Hi there @Aculimic, the first errors sound like filesystem permission errors.
Are you able to run the command ls -las on the directory where those files are so we can see if the errors relate to filesystem permissions. Are you running the script as sudo?

Hi @Raiko
I have the same issue as you describe - PiCroft Stretch with Google AIY kit works, but volume can not be controlled. I also have a SD card with PiCroft Jessie where I (accidently - don’t remember what I did) got Google AIY working including volume control. Right now I am comparing the Jessie and the Stretch installations, but this is a tedious task…

Hi @Dominik
Is it possible that on Jessie you used alsa and not pulseaudio?
Or maybe you used the VoiceHATs older drivers and way of installing it. I think they worked with alsa.

On Stretch I was thinking that maybe you need to install pulseaudio and configure in a specific way. As with instructions provided they dont really set up pulseaudio. At least on my image I have no daemon running. I installed pulseaudio-utils and when running pactl list it doesn’t work. Says connection refused. Also pacmd is not showing anything anymore.
Equally I havent found anything yet that suggests how to do it properly.