No Playback or Mic Input but all audio tests succeed

pi@raspberrypi:/var/log $ ls -la ~/.config/pulse/
insgesamt 68
drwx------ 2 pi pi 4096 Sep 7 08:55 .
drwx------ 19 pi pi 4096 Sep 6 21:44 …
-rw------- 1 pi pi 20480 Sep 6 12:14 9f3227c8b0614f26b7a19283224cfdf9-card-database.tdb
-rw------- 1 pi pi 1 Sep 7 08:55 9f3227c8b0614f26b7a19283224cfdf9-default-sink
-rw------- 1 pi pi 1 Sep 7 08:55 9f3227c8b0614f26b7a19283224cfdf9-default-source
-rw------- 1 pi pi 16384 Sep 6 12:57 9f3227c8b0614f26b7a19283224cfdf9-device-volumes.tdb
lrwxrwxrwx 1 pi pi 23 Sep 7 08:55 9f3227c8b0614f26b7a19283224cfdf9-runtime → /tmp/pulse-2L9K88eMlGn7
-rw------- 1 pi pi 12288 Sep 7 09:07 9f3227c8b0614f26b7a19283224cfdf9-stream-volumes.tdb
-rw------- 1 pi pi 256 Sep 2 18:29 cookie

Yes, paplay is working fine if I playback a WAV-File from the filesystem with paplay <file>
My ~/.mycroft/mycroft.conf just looks like this:

{
“max_allowed_core_version”: 20.8
}

I don’t have a file at /etc/mycroft/mycroft.conf

And yes mpg123 is able to playback mp3 files without problems…

UPDATE:
I think I made some progress. I tracked down the issue with PulseAudio and I think I solved it by adding a user-level systemd service for PulseAudio and enabled it. As you see in the systemd service file for mycroft (above) that it should be started after “pulseaudio.service” - this service was never created. I still don’t have audio from mycroft but now the logs changed:

2020-09-07 11:03:35.788 | INFO | 4634 | mycroft.audio.audioservice:load_services:105 | Loading simple 2020-09-07 11:03:35.798 | INFO | 4634 | mycroft.audio.audioservice:load_services:105 | Loading vlc [afb411c0] vlcpulse audio output error: PulseAudio server connection failure: Connection refused [afb9a690] vlcpulse audio output error: PulseAudio server connection failure: Connection refused 2020-09-07 11:03:35.982 | INFO | 4634 | mycroft.audio.audioservice:load_services_callback:177 | Finding default backend… 2020-09-07 11:03:35.983 | INFO | 4634 | mycroft.audio.audioservice:load_services_callback:181 | Found local 2020-09-07 11:03:35.985 | INFO | 4634 | main:on_ready:30 | Audio service is ready. 2020-09-07 11:04:58.434 | INFO | 4634 | mycroft.audio.speech:mute_and_speak:127 | Speak: hello High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 version 1.25.10; written and copyright by Michael Hipp and others free software (LGPL) without any warranty but with best wishes Expression ‘alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 924 2020-09-07 11:05:14.482 | INFO | 4634 | mycroft.audio.speech:mute_and_speak:127 | Speak: hello High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3 version 1.25.10; written and copyright by Michael Hipp and others free software (LGPL) without any warranty but with best wishes Expression ‘alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 924

If I start the mycroft-cli-client now I have a mic input level indicator and the wakeword is understood but there are still PulseAudio errors and no audio output. I can also ask questions and I got the answer in the cli but there are a lot of errors and no audio output…

Could’ve been so easy…

/etc/mycroft/mycroft.conf:

{
   "play_wav_cmdline": "paplay %1",
   "play_mp3_cmdline": "mpg123 %1",
   "enclosure": {
      "platform": "picroft"
   },
   "ipc_path": "/ramdisk/mycroft/ipc/"
}

~/.mycroft/mycroft.conf

{
  "lang": "de-de",
  "tts": {
    "module": "google",
    "google": {
      "lang": "de"
    },
    "pulse_duck": true
  },
  "max_allowed_core_version": 20.8,
  "hotwords": {
    "hey-mycroft": {
      "module": "precise",
      "local_model_file": "~/.mycroft/precise/hey-mycroft.pb"
    },
  },
  "listener": {
    "wake_word": "hey-mycroft"
  }
}

Relevant for that problem is

   "play_wav_cmdline": "paplay %1",
   "play_mp3_cmdline": "mpg123 %1",

yet, you should work in the other usefull parts (or at least take this as a template). And now i know why mycroft wanted to download the model

and for the sake of convenience, you should consider working in picrofts’ auto-run.sh (automated update process and mycroft start at bootup) instead of
the service bootup script (you need to adjust some administrative things though)

for the `` "pulse_duck": true to take effect
you need to alter /etc/pulse/defaults.pa

load-module module-role-ducking
unload-module module-role-cork
unload-module module-suspend-on-idle

That ensures one stream is ducking the other if it happens that 2 overlap each other

Since you’re still at the beginning of setting up mycroft, you might want to consider another option: Brew your own picroft image (using Raspberry OS full)

I made the changes you suggested but now I don’t have any Mic Level nor Output in the CLI again. I am not using the Picroft image - instead I followed this from the docs:
https://mycroft-ai.gitbook.io/docs/using-mycroft-ai/get-mycroft/linux
I installed Mycroft on an already running Raspberry Pi OS (32 Bit) (with PIXEL) which I already had in use. I don’t have that “auto-run.sh” file in my system.

I think the issue is still related to mycroft not being able to access PulseAudio correctly. All other applications work fine but Mycroft fails to use the systems audio… I don’t know what to do next. Maybe the latest Raspberry Pi OS is not working with Mycroft or my system is too messed up now. I will give it another try with a new SD Card and the picroft image or brewing my own image like you mentioned…

yeah, i know you don’t. And i do know you haven’t any auto_run.sh. But i suggest that you set up a picroft-image following the steps in the link i provided. Instead of Raspbian Buster Lite, you would go with the full pixel version.

if you don’t want to do that just use the lines (in the conf; which one doesn’t play a role)

"play_wav_cmdline": "paplay %1",
"play_mp3_cmdline": "mpg123 %1",

NOTE: This is JSON notation, so look ou for , or { or }

and toss the rest. This ONLY tells mycroft where to output stuff. (you’ve said paplay and mpg123 is working). From there go step by step.

May not be the issue here but an issue I had when working on the Mark-2 system services, to connect to pulse the service needed to set XDG_RUNTIME_DIRECTORY to the user’s runtime directory.

(Here’s one of the service-files.)

This could very well be the case since the pa_context_new() refuses connection which indicates some environmental problems.

This suggestion points to another route. Maybe a good suggestion if those problems mounting up or things getting more complex.

Hi again,
as I mentioned above I already created a user-level systemd service file - PulseAudio is working fine with that and all the errors I had with GUI tools (like pavucontrol) are gone. So the connection to PulseAudio is working perfectly. But Mycroft still seems to have difficulty to access the PA Server… Maybe the problem is, that I start Mycroft using a system-wide systemd service and PA is on a user-level now…

1 Like

Are the user that runs mycroft and pulseaudio the same?

Because your last error still says that mycroft can not access pulseaudio.

If you run pulseaudio systemwide, you also need a dbus setting to be configured correctly

Yes they are both running with the same user. I already tried the system-wide PulseAudio config (with DBus) but the error persisted. The best results are using the user systemd service. Still, mycroft is not able to use PA… very strange issue

BTW i’m guessing that the line
After=pulseaudio.service
is a fragment from older days, where this was handled differently. To my knowledge no mycroft distribution is setup that way by default. I wouldn’t deduct that this is a pathway.

And unless you manually set pulse audio to —system it was always running on a user level

and the addition to dbus

<allow send_destination="org.pulseaudio.Server"/>
<allow receive_sender="org.pulseaudio.Server"/>

isn’t default either

Safe yourself some serious headache, and brew yourself some picroft image.

Thank you again.
Yes I am already on my way for my own image. I am going for Rasp OS Lite, too which should give some performance improvements and less dependencies. I hope it’s going to work.
Thank you all for your time!

Or you give MycroftOS a spin😜

1 Like

Also, this should be a good read to know all the variables configureable in mycroft.conf

Hi again,
I managed to get Mycroft working using the Picroft image. But I had several bugs in the install process:

  1. No working USB devices after first start (needed full upgrade first)
  2. Can’t login using USB keyboard (sudo password required) - not recognized (even after update)
  3. Mycroft Services do not start automatically after boot

Login via SSH is working and I was able to get everything up and running (my USB microphone is officially unsupported but working!).
I am going to start my new system on this basis now.
Thread can be closed (but unsolved).