Hey guys, DietPi developer here. Dealing with a separate issue (permissions issue on skills dir our side), I ran some tests of our Mycroft AI implementation and indeed some things seem to have changed since I implemented it >1 year ago, and I’m currently trying to get everything working OOTB.
@Green
First of all, did you install Mycroft via dietpi-software
or manually using e.g. the dev_setup.sh
. Since you mention the mycroft
system user (that cannot be accessed via login shell as you found, trying su
, use sudo
instead, for interactive shell sudo -s
which is logged much better and is beneficial in other ways security-wise), it seems you installed it through dietpi-software
.
That also matches the mycroft.service
systemd unit.
The actual bug our side is missing skills dir permissions, as the official installer chown
s a symlink in our case but by default chown -R
does not traverse symlink targets. So the solution for that is: chown -R /mnt/dietpi_userdata/mycroft-data
Fixed for next DietPi release.
First audio-related thing is, we did intentionally not install PulseAudio in the past, since all other software implementations and our audio config script use ALSA and PA would mess up things here and is still (or will always be) known to have issues with many media software. So for now I aim to leave it like that and setup things to work with ALSA only OOTB. A few months after we created our implementation, PulseAudio became installed as dependency by dev_setup.sh
installer (which we use), so to no mess up things, this would need to be removed first. I hope for either a revert or an option to not force PulseAudio usage, as long as we get things running with plain ALSA, for now we’ll use a sed
to remove it.
@Green
If you are in mood to follow my tests, you could hence do:
apt -y purge pulseaudio pulseaudio-utils
apt -y autopurge
Next is, we use the ALSA hw
plugin, which does no audio conversions. That is fine with mpg123
and ogg123
but using aplay
for wav files may fail, if they’re not in a format that is supported by the audio device. Software conversions have some downsides as well, but to be flexible with different Mycroft AI sources and voices, including microphone capture, it makes sense to allow them via following ALSA configuration (invoking the “plug” plugin which does automated conversion, if required):
cat << '_EOF_' > /etc/asound.conf
pcm.!default {
type plug
slave.pcm {
type hw
card 0
device 0
}
}
ctl.!default {
type hw
card 0
}
_EOF_
You might need to use card 1
here for 3.5mm jack output after recent RPi firmware change, if an audio-capable HDMI monitor is attached.
I added an option to dietpi-config
to toggle automated format conversion with the next version.
To overcome issues with incompatible sample rates of recordings, we changed the default in our global mycroft.conf
, however that can be skipped then. This was the step that made Mycroft microphone capture even possible on a test system. Before, in mycroft-cli-client
the mic level bar was frozen shortly after start, while arecord tests worked fine. Not sure what the reason might be, but this is a different topic. To revert listener sample rate to Mycroft defaults:
curl -sSfL https://raw.githubusercontent.com/MichaIng/DietPi/dev/.conf/dps_176/mycroft.conf -o /etc/mycroft/mycroft.conf
This file btw as well sets the data directory (in to a location that can be easily setup as external drive, yes, to reduce SD card writes where possible while keeping the core OS there) and overrides the default command to play wav files (paplay
(PulseAudio)) with aplay
(ALSA).
After changes, a service restart makes sense: (sudo) systemctl restart mycroft
Then in CLI mycroft-cli-client
I see mic level dancing and most input and output works fine.
Switching setting on https://home.mycroft.ai/, while American and Google voices + Christopher, Ezra and Jarvis wake words work fine (okay I needed to learn how to pronounce “Jarvis” correctly ), the two defaults “Hey Mycroft” and “British Male” do not.
- In case of the wake word, I don’t see related error messages. Probably I’m pronouncing it wrong, but even the Google translator TTS is not able to wake it: https://translate.google.de/?text=Hey%20Mycroft!
- In case of the british voice, I indeed get a Python error trace:
2020-11-16 20:18:40.951 | DEBUG | 5511 | urllib3.connectionpool | Starting new HTTPS connection (1): api.mycroft.ai:443
2020-11-16 20:18:41.452 | DEBUG | 5511 | urllib3.connectionpool | https://api.mycroft.ai:443 "GET /v1/device/92204eb5-cbbc-4f2d-becc-926e654e11e4/subscription HTTP/1.1" 200 17
2020-11-16 20:18:41.463 | ERROR | 5511 | mycroft.tts.tts:create:529 | The TTS could not be loaded.
Traceback (most recent call last):
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/mimic_tts.py", line 187, in validate_connection
subprocess.call([BIN, '--version'])
File "/usr/lib/python3.7/subprocess.py", line 323, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1436, in _execute_child
executable = os.fsencode(executable)
File "/usr/lib/python3.7/os.py", line 809, in fsencode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/tts.py", line 519, in create
tts.validator.validate()
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/tts.py", line 435, in validate
self.validate_connection()
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/mimic_tts.py", line 189, in validate_connection
LOG.info("Failed to find mimic at: " + BIN)
TypeError: can only concatenate str (not "NoneType") to str
2020-11-16 20:18:41.465 | ERROR | 5511 | mycroft.audio.speech:handle_speak:99 | Error in mute_and_speak
Traceback (most recent call last):
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/mimic_tts.py", line 187, in validate_connection
subprocess.call([BIN, '--version'])
File "/usr/lib/python3.7/subprocess.py", line 323, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1436, in _execute_child
executable = os.fsencode(executable)
File "/usr/lib/python3.7/os.py", line 809, in fsencode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/dietpi_userdata/mycroft-core/mycroft/audio/speech.py", line 95, in handle_speak
mute_and_speak(chunk, ident, listen)
File "/mnt/dietpi_userdata/mycroft-core/mycroft/audio/speech.py", line 123, in mute_and_speak
tts = TTSFactory.create()
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/tts.py", line 519, in create
tts.validator.validate()
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/tts.py", line 435, in validate
self.validate_connection()
File "/mnt/dietpi_userdata/mycroft-core/mycroft/tts/mimic_tts.py", line 189, in validate_connection
LOG.info("Failed to find mimic at: " + BIN)
TypeError: can only concatenate str (not "NoneType") to str