USB Mic not working

Running PiCroft

I am trying to do the following:

Mycroft Mic: USB Microphone
Mycroft Audio: Built-in audio
Shairport-Sync: USB Audio

Everything works except the mic. I am getting no mic levels in CLI. However, if I run test-microphone it works fine. I tried hardcoding the mic in the pa config as recommended in another post but that doesn’t seem to do it.

The odd thing is that it was working last night just fine. This morning I removed the systemd startup script for Shairport and after that it stopped working. I have since reinstalled the script (just trying to get back to what had been working) but that didn’t fix anything.

Any suggestions on other things to try?

Thanks.

I have the following errors in the log:

01:35:37.214 - mycroft.client.speech.hotword_factory:create_hotword:268 - INFO - creating hey mycroft
~~~~nit__:125 - INFO - Found precise executable: /home/mycroft/.mycroft/precise/precise-stream/precise-stream
~~~~.243 - mycroft.client.speech.listener:create_wakeup_recognizer:264 - INFO - creating stand up word engine
01:35:37.246 - mycroft.client.speech.hotword_factory:create_hotword:268 - INFO - creating wake up
~~~~31 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.mycroft.ai
~~~~DEBUG - https://api.mycroft.ai:443 "GET /v1/device/f7fde974-67e2-484e-bfa4-d1bc3d60ee6b HTTP/1.1" 200 434
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
~~~~ inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818
Exception in thread Thread-16:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
~~~~python2.7/site-packages/mycroft_core-18.2.3-py2.7.egg/mycroft/client/speech/listener.py", line 55, in run
with self.mic as source:
~~~~thon2.7/site-packages/mycroft_core-18.2.3-py2.7.egg/mycroft/client/speech/mic.py", line 125, in __enter__
input=True,  # stream is an input stream
File "/usr/local/lib/python2.7/site-packages/pyaudio.py", line 750, in open
stream = Stream(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pyaudio.py", line 441, in __init__
self._stream = pa.open(**arguments)
IOError: [Errno -9998] Invalid number of channels

Sorry to hear you’re experiencing these issues, @bkmar1192. I haven’t seen that specific error message before, but it seems to be alsa related, rather than pulseaudio related. Do any of the alsa troubleshooting tips here help at all?

Yes, I have tried the troubleshooting steps but no help. With:

“listener”: {
“device_index”:0
}

I get:

Expression ‘parameters->channelCount <= maxChans’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 1514
Expression ‘ValidateParameters( inputParameters, hostApi, StreamDirection_In )’ failed in ‘src/hostapi/alsa/pa_linux_alsa.c’, line: 2818
Exception in thread Thread-16:
Traceback (most recent call last):
File “/usr/lib/python2.7/threading.py”, line 810, in __bootstrap_inner
self.run()
File “/usr/local/lib/python2.7/site-packages/mycroft_core-18.2.3-py2.7.egg/mycroft/client/speech/listener.py”, line 55, in run
with self.mic as source:
File “/usr/local/lib/python2.7/site-packages/mycroft_core-18.2.3-py2.7.egg/mycroft/client/speech/mic.py”, line 125, in enter
input=True, # stream is an input stream
File “/usr/local/lib/python2.7/site-packages/pyaudio.py”, line 750, in open
stream = Stream(self, *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/pyaudio.py”, line 441, in init
self._stream = pa.open(**arguments)
IOError: [Errno -9998] Invalid number of channels

with nothing in the config I get:

ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2’
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave

OK, that’s helpful. I’m away from my Picroft device at the moment, so I can’t replicate easily. Is the device_index that you’ve used here the one that was identified by listing sinks in the troubleshooting information? Do any other device_index settings work?

It isn’t real clear from eh directions what index is expected. When i run record -l I get:

pi@picroft:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Device [USB Audio Device], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

Is the index 0 or 1? Do I need to specify both a card and device?

running: pacmd list-sources

I get the following: is the index 3?

3 source(s) available.
index: 1
name: <alsa_output.platform-soc_audio.analog-stereo.monitor>
driver: <module-alsa-card.c>
flags: DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 1000
volume: front-left: 44544 / 68% / -10.06 dB, front-right: 44544 / 68% / -10.06 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max rewind: 0 KiB
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
configured latency: 0.00 ms; range is 0.50 … 743.04 ms
monitor_of: 1
card: 0 <alsa_card.platform-soc_audio>
module: 19
properties:
device.description = "Monitor of bcm2835 ALSA Analog Stereo"
device.class = "monitor"
alsa.card = "0"
alsa.card_name = "bcm2835 ALSA"
alsa.long_card_name = "bcm2835 ALSA"
alsa.driver_name = "snd_bcm2835"
device.bus_path = "platform-soc:audio"
sysfs.path = "/devices/platform/soc/soc:audio/sound/card0"
device.string = "0"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card"
index: 2
name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-stereo.monitor>
driver: <module-alsa-card.c>
flags: DECIBEL_VOLUME LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 1040
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max rewind: 0 KiB
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
fixed latency: 99.95 ms
monitor_of: 2
card: 1 <alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device>
module: 20
properties:
device.description = "Monitor of USB Audio Device Analog Stereo"
device.class = "monitor"
alsa.card = "1"
alsa.card_name = "USB Audio Device"
alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-3f980000.usb-1.3, full speed"
alsa.driver_name = "snd_usb_audio"
device.bus_path = "platform-3f980000.usb-usb-0:1.3:1.0"
sysfs.path = "/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/sound/card1"
udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device"
device.bus = "usb"
device.vendor.id = "0d8c"
device.vendor.name = "C-Media Electronics, Inc."
device.product.id = "0014"
device.product.name = "USB Audio Device"
device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
device.string = "1"
module-udev-detect.discovered = "1"
device.icon_name = “audio-card-usb”

  • index: 3
    name: <alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device.analog-mono>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9049
    volume: mono: 46396 / 71% / -9.00 dB
    balance 0.00
    base volume: 27111 / 41% / -23.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max rewind: 0 KiB
    sample spec: s16le 1ch 44100Hz
    channel map: mono
    Mono
    used by: 0
    linked by: 0
    fixed latency: 99.95 ms
    card: 1 <alsa_card.usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device>
    module: 20
    properties:
    alsa.resolution_bits = "16"
    device.api = "alsa"
    device.class = "sound"
    alsa.class = "generic"
    alsa.subclass = "generic-mix"
    alsa.name = "USB Audio"
    alsa.id = "USB Audio"
    alsa.subdevice = "0"
    alsa.subdevice_name = "subdevice #0"
    alsa.device = "0"
    alsa.card = "1"
    alsa.card_name = "USB Audio Device"
    alsa.long_card_name = "C-Media Electronics Inc. USB Audio Device at usb-3f980000.usb-1.3, full speed"
    alsa.driver_name = "snd_usb_audio"
    device.bus_path = "platform-3f980000.usb-usb-0:1.3:1.0"
    sysfs.path = "/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/sound/card1"
    udev.id = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00-Device"
    device.bus = "usb"
    device.vendor.id = "0d8c"
    device.vendor.name = "C-Media Electronics, Inc."
    device.product.id = "0014"
    device.product.name = "USB Audio Device"
    device.serial = "C-Media_Electronics_Inc._USB_Audio_Device"
    device.string = "hw:1"
    device.buffering.buffer_size = "8816"
    device.buffering.fragment_size = "2204"
    device.access_mode = "mmap"
    device.profile.name = "analog-mono"
    device.profile.description = "Analog Mono"
    device.description = "USB Audio Device Analog Mono"
    alsa.mixer_name = "USB Mixer"
    alsa.components = "USB0d8c:0014"
    module-udev-detect.discovered = "1"
    device.icon_name = "audio-card-usb"
    ports:
    analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
    properties:
    device.icon_name = "audio-input-microphone"
    active port:

OK, this might be a bit of a long shot, but I can’t think of anything else that might be useful here. You’ve used the correct device_index from what I can see, so it means that something else is going on. The device is showing as SUSPENDED, and I’ve seen the same thing a few times now on Picroft, without an adequate resolution.

I wonder if it’s worth trying to disable the module that suspends pulseaudio when it is idle?

This requires editing the file at /etc/pulse/default.pa

### Automatically suspend sinks/sources that become idle for too long
load-module module-suspend-on-idle
to this:

### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle