Picroft microphone issue


#1

Hey Mycroft
I have to admit I am still having problems with audio. He speaks well, but when I tell him to record the play-back sound quality is very poor. Also, when I say Hey Mycroft he doesn’t always hear, I have to go up close and speak quite loudly.

If I do ‘arecord -d10 /home/test-mic.wav’ and ‘aplay /home/test-mic.wav’ from the command line the sound quality is way better, which leads me to think that pycroft is’nt dealing with output from the mic very well.
Thanks for reading.


#2

:frowning: I am sorry that you hassnt w wellworking picroft. I hassnt any idea why or what could be done to fix that.
I know that either @gez-mycroft or @Forslund are kings when it comes to Linux, ALSA and pulse audio.
Speaking of which - do you have pulse audio installed ? Try install pulseaudio by

sudo apt-get install pulseaudio

What I see is that many problems regarding to audio is fixed by adding pulseaudio to the picroft.


#3

Thanks. I have installed puls audio


#4

Hi Aaron,

One thing to check would be your microft.conf files to see whether they are using the defaults for both sound devices. This was causing other peoples devices to not work, but it could equally be causing different behaviour to system level audio.

Can you run:
cat /etc/mycroft/mycroft.conf
and see if you can find the following two lines:
"play_wav_cmdline": "aplay %1"
"play_mp3_cmdline": "mpg123 %1"

Less likely but still possible is that they are in your user level conf file:
cat ~/.mycroft/mycroft.conf

If they have other flags or parameters then you can override them by adding the two lines above to your home directory’s mycroft.conf:
sudo nano ~/.mycroft/mycroft.conf

Let us know if that has any effect, and I’ll keep thinking about other possibilities…


#5

One thing to try is to try a different samplerate.

Try getting this script and check your default device.

cd mycroft-core
source venv-activate.sh
python list_inputs.py

Check the “default” device for samplerate

Then try adding a block in ~/.mycroft/mycroft.conf

  "listener": {
    "sample_rate": SAMPLERATE
  }

where SAMPLERATE is fetched from the output.

In the block you can also try to change device by adding

    "device_name": "somename"

You should be able to test the settings using the audiotest script provided with mycroft.

/Åke

EDIT: removed the reference to channels. these are hard coded to 1.


#6

Thanks

This is what I get when I do cat /etc/mycroft/mycroft.conf
-----------------------------------------------------------------
(.venv) pi@picroft:~ $ cat /etc/mycroft/mycroft.conf
{
_ “play_wav_cmdline”: “aplay %1”,_
_ “play_mp3_cmdline”: “mpg123 %1”,_
_ “enclosure”: {_
_ “platform”: “picroft”_
_ },_
_ “tts”: {_
_ “mimic”: {_
_ “path”: “/home/pi/mycroft-core/mimic/bin/mimic”_
_ }_
_ },_
_ “ipc_path”: “/ramdisk/mycroft/ipc/”_
}
-------------------------------------------------------------------------
I assume this is as it should be?


#7

Yeah, that all looks right, Ake’s suggestion of the sample rate is a good one to try too.

I should have a new RPi arriving in a few days (I only have 2’s at the moment) so will soon be tackling all these same problems!!!


#8

Hi forsland
Thanks but I am afraid I do not understand your instructions. I can cd to mycroft-core and ls to see venv-activate.sh, but I don’t know what to do with any of it.
Sorry


#9

so after you cd into the directory you can run

source venv-activate
wget goo.gl/TsUAaK -O list_inputs.py
python list_inputs.py

(I prepared a shortened url to the script linked above in case you’re typing directly into the picroft)
You should see something like this:
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave

==========================================
Found devices:
HD-Audio Generic: ALC892 Analog (hw:1,0): Samplerate 44100.0 Channels 2
HD-Audio Generic: ALC892 Alt Analog (hw:1,2): Samplerate 44100.0 Channels 2
pulse: Samplerate 44100.0 Channels 32
default: Samplerate 44100.0 Channels 32

where the part after Found devices is the interesting parts.

The part before the : Samplerate is the device name that can be entered into the config as described above

For example I could set the “device_name” to HD-Audio Generic: ALC892 Analog (hw:1,0) or pulse or any of the other devices.


#10

Also we’re preparing to add a mic selector in the mycroft-cli-client…


#11

I know I am doing something wrong here, but this is what I get when I try to follow your instructions.

(.venv) pi@picroft:~ $ cd mycroft-core
(.venv) pi@picroft:~/mycroft-core $ source venv-activate.sh
Entering Mycroft virtual environment. Run ‘mycroft-venv-deactivate’ to exit
(.venv) pi@picroft:~/mycroft-core $ python list_inputs.py
python: can’t open file ‘list_inputs.py’: [Errno 2] No such file or directory
(.venv) pi@picroft:~/mycroft-core $


pi@picroft:~/mycroft-core $ source venv-activate
-bash: venv-activate: No such file or directory
pi@picroft:~/mycroft-core $ wget goo.gl/TsUAaK -O list_inputs.py
–2019-01-30 13:01:21-- http://goo.gl/TsUAaK
Resolving goo.gl (goo.gl)… 216.58.206.78, 2a00:1450:4009:806::200e
Connecting to goo.gl (goo.gl)|216.58.206.78|:80… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: https://gist.githubusercontent.com/forslund/98b1db104a20876d055b31b854fa0565/raw/8724c58edf5e1bf19f19895ab116cf271264cbda/list_inputs.py [following]
–2019-01-30 13:01:21-- https://gist.githubusercontent.com/forslund/98b1db104a20876d055b31b854fa0565/raw/8724c58edf5e1bf19f19895ab116cf271264cbda/list_inputs.py
Resolving gist.githubusercontent.com (gist.githubusercontent.com)… 151.101.60.133
Connecting to gist.githubusercontent.com (gist.githubusercontent.com)|151.101.60.133|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 474 [text/plain]
Saving to: ‘list_inputs.py’

list_inputs.py 100%[===================>] 474 --.-KB/s in 0s

2019-01-30 13:01:21 (2.55 MB/s) - ‘list_inputs.py’ saved [474/474]

pi@picroft:~/mycroft-core $ python list_inputs.py


#12

Hi Aaron, apologies I just noticed there was a small typo in the instructions, the first line should be:
source venv-activate.sh

It looks like you got that the first time yourself, which brings you into the virtual environment aka venv, but then missed downloading the script so it gave you the “No such file or directory” error. The second time you tried it downloaded the script but as you weren’t in the venv it wouldn’t have found any devices and most likely gave you an error about pyaudio not being found.

Can you try it one more time with the updated first line, it should look like:

pi@picroft:~ $ cd ~/mycroft-core

pi@picroft:~/mycroft-core $ source venv-activate.sh
>>>> Entering Mycroft virtual environment.  Run 'mycroft-venv-deactivate' to exit

(.venv) pi@picroft:~/mycroft-core $ wget goo.gl/TsUAaK -O list_inputs.py
>>>> A lot of stuff about downloading...
>>>> Saving to: ‘list_inputs.py’
>>>> list_inputs.py 100%[===================>] 474 --.-KB/s in 0s
>>>> 2019-01-30 13:01:21 (2.55 MB/s) - ‘list_inputs.py’ saved [474/474]

(.venv) pi@picroft:~/mycroft-core $ python list_inputs.py

This final line should output something similar to what Forslund posted above. We’re just interested in what comes after “Found devices:”


#13

Thanks for holding my hand on this.
Here is the result of the above commands.

(.venv) pi@picroft:~/mycroft-core $ python list_inputs.py
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream

==========================================
Found devices:
default: Samplerate 44100.0 Channels 32
(.venv) pi@picroft:~/mycroft-core $

I’ve got no idea what to do now
smilieface


#14

Did you say in the other thread that you were using this Pi hat for a mic?
http://wiki.seeedstudio.com/ReSpeaker_2_Mics_Pi_HAT/

For some reason it isn’t showing up in the list of devices…


#15

I am having problems getting the audio to work correctly as well. I am using the ReSpeaker 4 microphone array. What I have done so far is:

  1. installed the kernel drivers
  2. installed pulseaudio
  3. configured mycroft to use the audio input
  4. rebooted several times

The appropriate part of my mycroft.conf looks like:

  "listener": {
      "sample_rate": 44100.0,
      "device_name": "seeed-4mic-voicecard: - (hw:1,0)"
  }

The list_inputs.py script shows this device as well as the default and pulseaudio ones. The mycroft-mic-test script works correctly and records audio and plays it back at acceptable levels (after using alsamixer to adjust the ADC input gain to 61).

However, the mycroft-cli only shows the microphone levels intermittently, I have not been able to determine a pattern, sometimes restarting mycroft a few times makes it work, sometimes not. In no cases are the default wake-words recognised.

Any suggestions?


#16

Apologies for replying to myself. To set the gain automatically on the microphone array, I modified audio_setup.sh by appending the following:

amixer -c 1 cset numid=5 19
amixer -c 1 cset numid=6 19
amixer -c 1 cset numid=7 19
amixer -c 1 cset numid=8 19

Where the array shows up as card #1 and channels 5,6,7,8 are the ADC channels for each microphone. For some reason by default the card has the digital channels (what are they used for?) with gains set reasonably and the analogue channels with gains set to the minimum.

Unfortunately, mycroft still doesn’t seem to want to hear anything.


#17

_Hi gez
Sorry your reply passed me by. No I couldn’t get the seedstudio hat to work (I saw one post that said it was incompatible with Pi3, and gave up) so I swapped it for a ‘raspiauduo pi hat’ Now the speakers work well but I have to talk very close to mycroft for him to hear.
Thanx