Permission problems with Mycroft

Hello again!

It seems there are some permission problems with the basic setup of Mycroft on DietPi. Following a basic installation and changing the ownership of the skills folder (according to https://dietpi.com/forum/t/problems-with-installing-mycroft/4606/4 )

speaker-test works fine. The mycroft speaker test does not work.

root@DietPi:~# mycroft-start audiotest
Already up to date.
Initializing...
Changing ownership of /opt/mycroft to user: root with group: root
Starting audiotest
 ========================== Info ===========================
 Input device: Default device @ Sample rate: 48000 Hz
 Playback commandline: aplay WAV_FILE

 ===========================================================
 ==         STARTING TO RECORD, MAKE SOME NOISE!          ==
 ===========================================================
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/mnt/extern/dietpi_userdata/mycroft-core/mycroft/util/audio_test.py", line 132, in <module>
    main()
  File "/mnt/extern/dietpi_userdata/mycroft-core/mycroft/util/audio_test.py", line 119, in main
    record(args.filename, args.duration)
  File "/mnt/extern/dietpi_userdata/mycroft-core/mycroft/util/audio_test.py", line 66, in record
    with mic as source:
  File "/mnt/extern/dietpi_userdata/mycroft-core/mycroft/client/speech/mic.py", line 140, in __enter__
    return self._start()
  File "/mnt/extern/dietpi_userdata/mycroft-core/mycroft/client/speech/mic.py", line 151, in _start
    input=True,  # stream is an input stream
  File "/mnt/extern/dietpi_userdata/mycroft-core/.venv/lib/python3.7/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/mnt/extern/dietpi_userdata/mycroft-core/.venv/lib/python3.7/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9996] Invalid input device (no default output device)
root@DietPi:~# speaker-test

speaker-test 1.1.8

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 512 to 65536
Period size range from 512 to 65536
Using max buffer size 65536
Periods = 4
was set period_size = 16384
was set buffer_size = 65536
 0 - Front Left
Time per period = 1.382565
 0 - Front Left
Time per period = 2.729995
 0 - Front Left

If I start mycroft-cli-client and give it a command (for example, “set timer”), it will ask me for how long the timer should be set, and then I can respond with my voice and it understands, so it’s not a problem here. It’s just for the wake word.

After some discussion on the mycroft forum, it seems the problem is that mycroft (the user that was installed during the installation of Mycroft) can’t access pulseaudio, or there is some problem with default devices.

root@DietPi:~# cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:
floppy:x:25:
tape:x:26:
sudo:x:27:
audio:x:29:pulse,root,mycroft
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:root
sasl:x:45:
plugdev:x:46:
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
systemd-journal:x:101:
systemd-timesync:x:102:
systemd-network:x:103:
systemd-resolve:x:104:
input:x:105:
kvm:x:106:
render:x:107:
crontab:x:108:
netdev:x:109:
messagebus:x:110:
bluetooth:x:112:
spi:x:999:
i2c:x:998:
gpio:x:997:
rdma:x:115:
systemd-coredump:x:996:
dietpi:x:1000:
mysql:x:111:
redis:x:113:www-data
pihole:x:995:www-data
pulse:x:114:root
pulse-access:x:116:root
mycroft:x:994:

Any ideas how to solve this?

ok let’s test following

sudo -u mycroft speaker-test
root@DietPi:~# sudo -u mycroft speaker-test

speaker-test 1.1.8

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 512 to 65536
Period size range from 512 to 65536
Using max buffer size 65536
Periods = 4
was set period_size = 16384
was set buffer_size = 65536
 0 - Front Left
Time per period = 1.385322
 0 - Front Left

Working as intended.

hmm the test is executed as user mycroft. Usually that means the user has access?

MichaIng any ideas?

Is there a difference between access to microphone and access to speakers? Since speakers are giving me no problem so far.

honestly I never used a microphone on my RPi3B+. Therefore I’m not 100% sure. Probably user would need to be added to an additional group to grand access to the mic.

MichaIng do you know?

It’s been a while but I remember running into issues with the microphone as well at the start when implementing Mycroft AI. A problem might be the recent separation of output devices on RPi, i.e. HDMI and the 3.5mm jack are now different “cards” in ALSA interface which probably means that, when using HDMI for sound output, one must add a separate configuration block for the microphone which is on the 3.5mm card.

The audio group permits not only speakers but microphones as well btw.

But all that might not even be relevant since all is running through PulseAudio now? That is actually a bad thing, not controllable by us anymore, when it fails to work OOTB. Since there is another open issue with Mycroft AI I’ll now spin one up myself, but on VM for the start.

EDIT: Dammit: https://github.com/MycroftAI/mycroft-core/commit/f0fcba4b01ca6c39b7aa8e9671934fd6ea9eaab6
We could manually remove those dependencies from the script. We actively pre-configure Mycroft to use ALSA, so that should not be an issue.

PA might even be the reason for broken microphone, at least I’d try the following to restore to how it was when we implemented it the first time: apt purge pulseaudio pulseaudio-utils

In my case, I’m using the 3.5mm jack for speakers and USB for microphone, nothing on HDMI. AlsaMixer detects two sound cards:

Headphones obviously has no “Capture” controls, while the Blue Snowball (my microphone) has no “Playback” controls (as expected).


According to the guide, they do.

Thank you for your time.