Mycroft on RasPi4 - output delayed

Hi,

I want to install mycroft on raspbian and in principle it’s working. However, the output is delayed and there are some more strange bugs.
I followed the installation instructions for linux, confirmed everything (except the mimic installation), and received a warning about libjack-jackd2-0. But in principle it worked.
I had to change default-sample-rate = 16000 in /etc/pulse/daemon.conf because otherwise my microphone wasn’t working. In addtion, I set the speaker as mycroft-config set listener.device_name "USB Device 0x46d:0x825: Audio"
Now, here is the problem: The wake-word is detected immediately, but the recording starts with many seconds delay. Furthermore, there is no confirmation sound.
The debug output is:

21:38:47.617 | INFO     |  4977 | __main__:handle_wakeword:71 | Wakeword Detected: hey mycroft
Failed to drain stream: Timeout
 21:39:20.468 | INFO     |  4977 | __main__:handle_record_begin:41 | Begin Recording...
 21:39:23.676 | INFO     |  4977 | __main__:handle_record_end:49 | End Recording...
 21:39:26.409 | INFO     |  4977 | __main__:handle_utterance:76 | Utterance: ['what time is it']

According to some answers, I set "play_wav_cmdline": "paplay %1", in mycroft-core/mycroft/configuration/mycroft.conf. This did not change anything. However, giving some wrong input like "play_wav_cmdline": "paplay %1 --asdf", makes it record immediately.
Nevertheless, the output takes some time. Here is, the content of the log files:

==> voice.log <==
2021-03-25 20:07:52.170 | INFO     |   982 | __main__:handle_wakeword:71 | Wakeword Detected: hey mycroft
paplay: unrecognized option '--asdf'
2021-03-25 20:07:52.210 | INFO     |   982 | __main__:handle_record_begin:41 | Begin Recording...
2021-03-25 20:07:54.901 | INFO     |   982 | __main__:handle_record_end:49 | End Recording...
2021-03-25 20:07:56.177 | INFO     |   982 | __main__:handle_utterance:76 | Utterance: ['what time is it']

==> skills.log <==
2021-03-25 20:08:01.044 | INFO     |   976 | QuestionsAnswersSkill | Searching for what time is it
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
The current time is 9:08:02 P.M. Central European Time, Thursday, March 25, 2021
2021-03-25 20:08:02.881 | INFO     |   976 | QuestionsAnswersSkill | Answer from fallback-wolfram-alpha.mycroftai
Removing event fallback-query.mycroftai:QuestionQueryTimeout
Removing event fallback-query.mycroftai:QuestionQueryTimeout
2021-03-25 20:08:03.259 | INFO     |   976 | QuestionsAnswersSkill | Timeout occured check responses
2021-03-25 20:08:03.264 | INFO     |   976 | QuestionsAnswersSkill | Handling with: fallback-wolfram-alpha.mycroftai

==> audio.log <==
2021-03-25 20:08:03.273 | INFO     |   979 | mycroft.audio.speech:mute_and_speak:127 | Speak: The current time is 9:08:02 P.M.Central European Time, Thursday, March 25, 2021

==> skills.log <==
2021-03-25 20:08:03.277 | INFO     |   976 | WolframAlphaSkill | Setting information for source

==> audio.log <==
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

Directory: /tmp/mycroft/cache/tts/GoogleTTS/
Playing MPEG stream 1 of 1: 25c6ee2a5da73a0cfa56f49c40aed181.mp3 ...

MPEG 2.0 L III cbr32 24000 mono

[0:09] Decoding of 25c6ee2a5da73a0cfa56f49c40aed181.mp3 finished.

On a picroft, it’s much faster and the output text is different.

To sum it up, there a three/four problems:

  1. Why do I have to give an invalid play_wav_cmdline to start the recording?
  2. Where is the confirmation sound? ("confirm_listening": true, is set in mycroft-core/mycroft/configuration/mycroft.conf)
  3. Why is the respone slow?
  4. What turned the time output into this detailed output?
  1. You don’t. The delay you’re experiencing is (probably) while it’s supposed to be playing the confirmation sound, using paplay. Something’s going wrong playing the sound, and it’s taking a moment to finish failing. However, when you change it to an invalid command, it fails immediately.
  2. See 1. The start_listening sound is located in res/snd. As a first step, see if you can paplay it directly.
  3. The response seems slow because that’s not the datetime skill, for some reason. Try running :skills in the cli client, and see if the datetime skill appears to be working. Instead, Mycroft invoked the Q&A skill, which takes noticeably longer, because it’s a multi-step process where it asks other skills which of them can answer the question.
  4. The Q&A skill got a reply from Wolfram Alpha, which is the output you see up there. The output you see on Picroft is the output from the datetime skill (which is included by default, so it really oughta be working out of the box)

Thanks for the fast and helpful reply.
The date-time problem (no 3 & 4) was easy to solve. The package libatlas-base-dev was missing. sudo-apt get install libatlas-base-dev was all I had to do.

For the first two problems, I compared the output of mycroft-config get for both installations. It turned out that setting "play_wav_cmdline": "aplay -Dhw:0,0 %1" is a good solution. However, I do not understand why paplay wasn’t working. It can play a wave file recored with arecord. I even compared the files in /etc/pulse and /etc/alsa without any difference. And I found no additional files in /etc that seem to relate to audio.

The only drawback it that the response is slightly delayed. It’s not severe. Perhaps, I will have a closer look into auto_run.sh to sea what picroft sets up.

Playing WAVE '/home/pi/mycroft-core/mycroft/res/snd/start_listening.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
2021-03-26 21:36:18.021 | INFO     | 10853 | __main__:handle_record_begin:41 | Begin Recording...
2021-03-26 21:36:20.646 | INFO     | 10853 | __main__:handle_record_end:49 | End Recording...
2021-03-26 21:36:21.989 | INFO     | 10853 | __main__:handle_utterance:76 | Utterance: ['what time is it']

==> audio.log <==
2021-03-26 21:36:26.971 | INFO     | 10850 | mycroft.audio.speech:mute_and_speak:127 | Speak: twenty two thirty six
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

Directory: /tmp/mycroft/cache/tts/GoogleTTS/
Playing MPEG stream 1 of 1: afdbbf3893762fcac394ad2d67a3908e.mp3 ...

MPEG 2.0 L III cbr32 24000 mono

[0:02] Decoding of afdbbf3893762fcac394ad2d67a3908e.mp3 finished.

Yeah, the Picroft config may reflect peculiarities of Raspbian. I hadn’t considered that possibility. Likelihood, even.