I have followed installation guides and audio troubleshooting, but my case isn’t addressed in this documentation.
The fact is that I installed a GPIO mic&loudspeaker wm8960 board, and “aplay -l” shows correctly the card available as “Card 2”. alsamixer also shows the card and lets configure both its mic and loudspeakers volumes.
In /usr/share/alsa/alsa.conf I’ve set
With all this, no sound is either played or recorded. speaker-test and “mycroft-start audiotest” don’t work.
I’ve executed “mycroft-start audiotest -l” and I’ve realized that several errors are reported by ALSA lib for pcm, pulse, etc telling “unknown pcm”, “unable to connect” and “unable to open slave”, and at the end the output says “ALSA lib pcm_hw.c: 1822:(_snd_pcm_hw_open) Invalid value for card”, “aplay: main: 828: audio open error: No such device” and “An error occurred while playing back audio”.
Before those final error reports, the “mycroft-start audiotest -l” execution shows as audio devices just “0: Dummy: PCM (hw: 0,0)”, but no trace of my wm8960 which is as “Card 2” when executing “aplay -l”…
Any clue of what might be happening? It seems as if Mycroft just can’t see my soundcard, but I just don’t know why nor how to fix it. I’d appreciate any help. Thx.
That can confuse and audio-setup,sh can also.
Mycroft plays via various outputs that can be a mixture of pulseaudio & alsa.
I would check the mycroft conf and maybe just delete the hardware index bits and continue as you are, paplay should work but maybe also set /etc/pulse/default.pa with sinks and sources at the end of the conf.
Do your tests first
Recording with arecord does generate a .wav file with kbytes, but when I execute aplay to play this .wav file, it doesn’t play it reports an err or that the device is busy… I assumed that a running Mycroft just took the audio soundcard playing hardware…
You gave me an important hint. 3 cards was too much, and I’m afraid that, after too many trials, my installation wasn’t reliable anymore.
After all what I’ve been able to learn from all this, I reinstalled from scratch. And I made a huge progress: now the arecord and aplay both work very smoothly: I can save a Mycroft_test.wav file and hear it afterwards.
But… I encountered a new source of error. Now it seems as if mycroft doesn’t use the mic properly, as when I execute “mycroft-start audiotest” it seems to record and generates a /tmp/test.wav file, but fails to play it afterwards. The reason why I think mycroft doesn’t record properly is because “aplay -Dhw:0 /tmp/test.wav” fails as well, but if I place my previous Mycroft_test.wav (which was played ok) in /tmp/test.wav, then the “aplay -Dhw:0 /tmp/test.wav” works alright. The problem is the file saved from the mic by mycroft.
Hence, I had a look at sinks and sources with “pactl info” and there’s in “Default source” a “alsa_input.platform-soc_sound.stereo-fallback” which seems to be ok, as when executing “pactl list sources short” the only input listed is that same “alsa_input.platform-soc_sound.stereo-fallback”.
But no input audio is accessible by mycroft from the mic. As another test, when I execute “mycroft-cli-client”, the mic area remains blank, without any variation on the screen when I speak.
Any idea? Is there any option to set input parameters for the mic which might not be correct? Thx again.
Update after some more testing and after changing sinks and sources with better results. Now it seems that I do need to change the default audio sample rate. What I found out:
Remember we’ve got two audios, one recorded by myself with parecord (Prueba_mycroft.wav) and another recorded by mycroft-start audiotest (/tmp/test.wav).
“paplay Prueba_mycroft.wav” and “paplay /temp/test.wav” work both of them and play the audio. On the contrary, with aplay “aplay -Dhw:0 Prueba_mycroft.wav” works alright (it says it’s an audio with “Rate 44100 Hz, Stereo”), and “aplay -Dwh:0 /tmp/test.wav” doesn’t work at all and reports the same error as “mycroft-start audiotest” (when playing, aplay says it’s and audio with “Rate 16000 Hz, Mono” and exits with an error “Channels count non available”).
Hence, the only thing that makes a difference between what works and what doesn’t work is the Rate (44100 vs 16000) and Mono vs Stereo. 44100 and Stereo work both paplay and aplay -Dhw:0. 16000 and Mono work with paplay, and fail with aplay -Dhw:0. I think that if I could make it to make mycroft record at 44100 and Stereo the thing would work, but I haven’t found how to configure this parameter either in /etc/mycroft/mycroft.conf, /etc/asound.conf
Thats wierd but yeah Mycroft records at Mono 16Khz (wideband audio) from memory.
Yeah records to /tmp or at least mic levl or something. Which actually you will have to remind me as I clone Mycroft-core from git and install as not keen on the Picroft image.
Because of that I can not remember if /tmp is tmpfs or sd card. df -h is my usual if I want to have a look at drives and mountpoints /tmp should be listed there or its just in the /root of the sdcard.
I guess its trying to playback at card default of 44Khz with a 16khz file.
You can aplay -v file.wav and that will give you all the audio info on that file.
I am shrugging my shouders as I don’t think I have ever had any problems with playback or need to specify a sample rate.
if you play with a aplay --help -r rate - c channels 1600/1 until its right maybe, but pulseaudio generally just plays and does this for you.
Still waiting for my 4 mic respeaker to turn up been using a ps3 eye cam for mic or a cmedia usb which actually is my headset.
I just had a look in /tmp and dont see any wav files,
I know it does process there as I bind mounted some zram there to stop sd wear.
pi@raspberrypi:/tmp $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 5.1G 8.8G 37% /
devtmpfs 841M 0 841M 0% /dev
tmpfs 970M 0 970M 0% /dev/shm
tmpfs 970M 8.6M 962M 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 970M 0 970M 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 53M 200M 21% /boot
/dev/zram1 198M 804K 181M 1% /opt/zram/zram1
overlay1 198M 804K 181M 1% /tmp
tmpfs 194M 4.0K 194M 1% /run/user/1000
As you will see its mounted as an overlayfs with zram1 being the writable upper.
I am also a relative linux audio noob as its always been something under the hood that I have never touched before, was just there in part of the desktop whilst its server I usually config.
Guess try playing back with defined rate and channel and whatever you can gleam from -v.
What does paplay do with that file.
Also you might want to do a pacmd list-sources / pacmd list-sinks and set the defaults rather than that intel thing whatever default that is.
The 2 mic is pretty standard in channel maps so to be honest confused and maybe its dodgy drivers or even sd card maybe?
PS I also usually setup pulseaudio Echo Cancellation and never set defaults as they are usually picked up but try this as its the norm how I run.
Just remark out you cuurent defaults in /etc/pulse/default.pa and tack this on the end.
Slightly bemused as thought it was a pulse-audio stream and not wav file.
If you struggle try mycroft-core as its dead easy and it makes more sense when you install yourself as its cleaner and has less confusing user scripts and config.
Clone and install via dev-setup.sh just press Y
do your raspi-config disable internal audio via config.txt and set it to autoboot via cli.
It will not run unless you cd ~/mycroft-core
I just edit .profile_mycroft to
if ! [[ :$PATH: == *:"/home/pi/mycroft-core/bin":* ]] ; then
if [ -d "/home/pi/mycroft-core/bin" ] ; then
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
bash start-mycroft.sh all &
and systemctl --user enable pulseaudio and raspi-config enable cli auto-login then reboot
sudo apt-get install git
git clone https://github.com/StuartIanNaylor/zram-config
sudo sh install.sh
sudo nano /etc/ztab
As to stop that /tmp sd card write I do my zram thing which is as easy as editing /etc/ztab
That is my Pi42Gb setup using half the ram with 100M for /tmp and if on less than a pi4 do after Mycroft-core install as must have heavy section of compressed files.
With ram its approx half what you have and with lz4 assume in general it will give a compressed disk size of 220%
I wish raspbian in the kernel config would enable the wrireback cache as presume it would push out to sd swap if not enough room rather than fail.
Dunno why they have installed the module but diabled one of its parameters of writeback cache but hey.
You did install the drivers?
PS I am prob confusing also and i missed and confused this when I started
You can use HW or PCM devices to list hardware (cards) its -l PCM devices are -L
As I could ref like so alsabat -Cplughw:CARD=CameraB409241,DEV=0 --standalone
PS don’t ask me about alsabat Basic Audio Tester as my feeble mind struggles to comphrehend
Probably we should be accessing PCMs rather than HW as they are not direct and have software conversion included if you pick the right one.
So if you wanted software conversion you would send it to the PCM device no the hardware device.
If I arecord -Dhw:CARD=CameraB409241,DEV=0 -f S16_LE -r 16000 -c 4 test.wav
pi@raspberrypi:~ $ aplay test.wav
Playing WAVE ‘test.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Channels 4
aplay: set_params:1345: Channels count non available
but aplay -Dplughw:CARD=ALSA,DEV=0 test.wav will work.
So its confusing as really we should be using the pcm devices not hw direct ones as it expects direct mappings…
Problem is I have ps3eye where there are problems anyway and still waiting for a respeaker.
But mycroft should work on defaults and playing that back direct might not work anyway.
As its not doing the software conversion of mono to stereo.
Do a -L and find the plughw for it and use that
But mycroft should be listening
PS don’t disable onboard audio as you prob need to modprobe blacklist it also.
If you disable it its still there just with no overlay and it causes probs at least on the Pi4.
Hi, thx so much for all this info. Thanks to it and some more findings, I’ve been able to reach a solution that definitely works.
What worked for me:
I set up an intermediate plug in that converts the audio format by placing in ~ the following content in a .asoundrc file:
(“aplay -l” tells me that my soundcard is configured in the slot card number 0, the reason why above I wrote “card 0”)
(channels 1 is to handle the mono-stereo conversion)
At the same time, I simplified the aplay that mycroft executes by changing the configured aplay command found in /etc/mycroft/mycroft.conf to the following command “aplay %1”
I noticed with the Pi4 when I turned off the onboard audio this caused errors with ALSA as the dtparam= audio =off in config.txt doesn’t seem to disable just doesnt load the overlay.
So if you need to disable onboard modprobe blacklist it also or just blacklist.
Disable onboard audio.
Open /etc/modprobe.d/raspi-blacklist.conf and add blacklist snd_bcm2835 .
Allow the USB audio device to be the default device.
Open /lib/modprobe.d/aliases.conf and comment out the line options snd-usb-audio index=-2
Thought I would just post a few extras now you have got a solution and that you seem comfortable with either a /etc/asound.conf (system) or ~/,asoundrc (user) alsa config.
name "Mic Gain"
The above asound is me fighting with the PS3eye and most can ignore the “array_gain” softvol that I created to try and override the control error the PS3eye gives.
You might want to grab the route_policy sum and change to how many channels you have as think the default with mono is just to pull from the 1st available channel whilst the route_policy sum of all channels might give better results.
I thought I would post as those who use 2 cards commonly the internal Pi audio and a Mic card can be very confused on how to set a default with Alsa.
Its there at the end and in the type asym.
You can’t do asym with ctl devices so you just going to have to pick one or another.
But thought I would also mention that you pick the plughw from aplay -L or the fixed rate PCM you created and don’t use direct hardware indexes as they have no software conversion.
With asym you can have different sampling rates for sink/source or different cards and maybe set a capture sampling rate but leave playback open but use a device that supports software sampling conversion (plughw: from aplay -L) so it will play whatever is presented.
The mycroft config of picroft is confusing as when using standard alsa-utils it can be a mystery to why the default device isn’t changing because its hard coded for media to use alsa by a hw:index which like you did just delete and set a default.
Mycroft voice actually uses pulseaudio not for any reason as if you look at mycroft/configuration/mycroft.conf you will see a line with a paplay %1 --stream-name=mycroft-voice.
You can just change that to aplay %1 but don’t edit the default conf do it the correct way and do it in /etc/mycroft/mycroft.conf just have a look so you know the line to override.
After that Mycroft becomes alsa only and I think easier and more simple to config.
Glad you got it all going @Blau and thought I would add some further tips if you wish and for anyone else who might be confused at whats going on with picroft audio.
@Blau Hey if you get a chance try out the EC from https://github.com/voice-engine/ec as if you do a “Hey Mycroft play the news” unfortunately you might end up with the Forrest Gump of voice and getting him to stop will be a chore.
Now your getting to grips with asound.conf EC shouldn’t be that hard but for many it can be daunting also from the info we get EC stops when each recording stops.
sudo apt-get -y install libasound2-dev libspeexdsp-dev
git clone https://github.com/voice-engine/ec.git
Also include the fifo
git clone https://github.com/voice-engine/alsa_plugin_fifo.git
make && sudo make install
You might want to open 3 console windows with ssh so you can start-mycroft.sh all and stop-mycroft.sh, at first so you can see the output and that all is running.
You need EC running before Mycroft so first just stop.
You will have to change the asound naming we have given but you saw my setup in above so you can prob work out how to adapt yours.
In another console run ./ec -i 'cap' -o 'plughw:CARD=ALSA,DEV=0'
I found EC what end on each end of recording whilst it needs to be continuous so I loaded a loopback via sudo modprobe snd-aloop
Then piped that into the first half of a loopback with arecord -D eco -q -r 16000 -f S16_LE -c 2 | aplay -D plughw:CARD=Loopback,DEV=0
My asound.conf now becomes
And as you see the other side of the loopback is now a constant EC source that doesn’t drop.
If you do a df -h just make sure /tmp is either tmpf or zram as it will be a shed load of writes but also create load writing and reading a constant stream like that to slow media.
With EC for can just precede the normal mycroft-start all in .profile-mycroft
with the ec command with bash ~/ec/ec -i 'cap' -o 'plughw:CARD=ALSA,DEV=0' & arecord -D eco -q -r 16000 -f S16_LE -c 2 | aplay -D plughw:CARD=Loopback,DEV=0 &
It will be interesting as will be weeks before I get a 2 mic delivered but that ps3eye is being shelved.
The above has all my naming for alsa and cards used and will just need adopting to yours.
With the output of the EC set as a default from the otherside of the loopback plughw:CARD=Loopback,DEV=1 it will just record & work like a normal default.