Pi Zero W with USB Souncard and Lav Mic

Hi,

I received a Pi Zero W and the following usb sound card and mic for Christmas:

Soundcard:
https://www.amazon.co.uk/gp/product/B00IRVQ0F8/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

Mic:

I am trying to get a standalone instance of Rhasspy working on the Pi Zero W so I followed the instructions in the docs to install via Docker, however I am struggling to get it working successfully.

My first question is, is this possible or can the Zero only be used as a satellite in a master / satellite setup (due to hardware limitations)?

If it is possible to use the Zero as a standalone instance then I need some advice about the setup of the soundcard and mic.

My Setup:
Pi Zero W, with Raspbian Lite and Rhasspy 2.5.8 (installed via Docker)

My Rhasspy Settings:

I am using Send events to Home Assistant.

Questions:

  1. In Audio Recording, which device should I select?

From reading the docs and posts online I know that the working device should have a star beside it or say working! - however the only option that has this is for a null device.

I tried most sensible options (basically every one except those that start “Number Surround Output” but I get no response when I say the wake word (porcupine).

  1. This is my log when I start Rhasspy:
[DEBUG:2020-12-30 16:40:10,896] rhasspyprofile.download: speech_to_text.deepspeech.mix_weight >0 0 = False
[DEBUG:2020-12-30 16:40:10,891] rhasspyprofile.download: speech_to_text.kaldi.mix_weight >0 0 = False
[DEBUG:2020-12-30 16:40:10,802] rhasspyprofile.download: speech_to_text.pocketsphinx.mix_weight >0 0 = False
[DEBUG:2020-12-30 16:40:10,782] rhasspyprofile.download: speech_to_text.deepspeech.open_transcription True False = False
[DEBUG:2020-12-30 16:40:10,722] rhasspyprofile.download: speech_to_text.kaldi.open_transcription True False = False
[DEBUG:2020-12-30 16:40:10,692] rhasspyprofile.download: speech_to_text.pocketsphinx.open_transcription True False = False
[DEBUG:2020-12-30 16:40:10,665] rhasspyprofile.download: speech_to_text.system deepspeech pocketsphinx = False
[DEBUG:2020-12-30 16:40:10,651] rhasspyprofile.download: speech_to_text.system kaldi pocketsphinx = False
[DEBUG:2020-12-30 16:40:10,601] rhasspyprofile.download: Skipping acoustic_model/variances (/profiles/en/acoustic_model/variances)
[DEBUG:2020-12-30 16:40:10,581] rhasspyprofile.download: Skipping acoustic_model/transition_matrices (/profiles/en/acoustic_model/transition_matrices)
[DEBUG:2020-12-30 16:40:10,532] rhasspyprofile.download: Skipping acoustic_model/noisedict (/profiles/en/acoustic_model/noisedict)
[DEBUG:2020-12-30 16:40:10,492] rhasspyprofile.download: Skipping acoustic_model/mixture_weights (/profiles/en/acoustic_model/mixture_weights)
[DEBUG:2020-12-30 16:40:10,472] rhasspyprofile.download: Skipping acoustic_model/means (/profiles/en/acoustic_model/means)
[DEBUG:2020-12-30 16:40:10,442] rhasspyprofile.download: Skipping acoustic_model/mdef (/profiles/en/acoustic_model/mdef)
[DEBUG:2020-12-30 16:40:10,382] rhasspyprofile.download: Skipping acoustic_model/feature_transform (/profiles/en/acoustic_model/feature_transform)
[DEBUG:2020-12-30 16:40:10,352] rhasspyprofile.download: Skipping acoustic_model/feat.params (/profiles/en/acoustic_model/feat.params)
[DEBUG:2020-12-30 16:40:10,322] rhasspyprofile.download: Skipping g2p.corpus (/profiles/en/g2p.corpus)
[DEBUG:2020-12-30 16:40:10,292] rhasspyprofile.download: Skipping g2p.fst (/profiles/en/g2p.fst)
[DEBUG:2020-12-30 16:40:10,252] rhasspyprofile.download: Skipping base_dictionary.txt (/profiles/en/base_dictionary.txt)
[DEBUG:2020-12-30 16:40:10,212] rhasspyprofile.download: speech_to_text.system pocketsphinx pocketsphinx = True
[INFO:2020-12-30 16:40:06,120] rhasspyserver_hermes: Started
[DEBUG:2020-12-30 16:40:06,082] rhasspyserver_hermes: Subscribed to hermes/asr/textCaptured
[DEBUG:2020-12-30 16:40:06,049] rhasspyserver_hermes: Subscribed to hermes/hotword/+/detected
[DEBUG:2020-12-30 16:40:06,002] rhasspyserver_hermes: Subscribed to hermes/audioServer/office/audioSummary
[DEBUG:2020-12-30 16:40:05,962] rhasspyserver_hermes: Subscribed to hermes/nlu/intentNotRecognized
[DEBUG:2020-12-30 16:40:05,922] rhasspyserver_hermes: Subscribed to rhasspy/asr/office/office/audioCaptured
[DEBUG:2020-12-30 16:40:05,862] rhasspyserver_hermes: Subscribed to hermes/intent/#
[DEBUG:2020-12-30 16:40:05,842] rhasspyserver_hermes: Subscribed to hermes/audioServer/office/audioSummary
[DEBUG:2020-12-30 16:40:05,792] rhasspyserver_hermes: Subscribed to rhasspy/asr/office/office/audioCaptured
[DEBUG:2020-12-30 16:40:05,762] rhasspyserver_hermes: Subscribed to hermes/nlu/intentNotRecognized
[DEBUG:2020-12-30 16:40:05,712] rhasspyserver_hermes: Subscribed to hermes/intent/#
[DEBUG:2020-12-30 16:40:05,700] rhasspyserver_hermes: Subscribed to hermes/asr/textCaptured
[DEBUG:2020-12-30 16:40:05,632] rhasspyserver_hermes: Subscribed to hermes/hotword/+/detected
[DEBUG:2020-12-30 16:40:05,601] rhasspyserver_hermes: Connected to MQTT broker
[DEBUG:2020-12-30 16:40:05,533] rhasspyserver_hermes: Connecting to localhost:12183 (retries: 2/10)
[ERROR:2020-12-30 16:40:04,519] rhasspyserver_hermes: mqtt connect
Traceback (most recent call last):
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 289, in start
    self.client.connect(self.host, self.port)
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address
[DEBUG:2020-12-30 16:40:04,507] rhasspyserver_hermes: Connecting to localhost:12183 (retries: 1/10)
[ERROR:2020-12-30 16:40:03,485] rhasspyserver_hermes: mqtt connect
Traceback (most recent call last):
  File "/usr/lib/rhasspy/rhasspy-server-hermes/rhasspyserver_hermes/__init__.py", line 289, in start
    self.client.connect(self.host, self.port)
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 1071, in reconnect
    sock = self._create_socket_connection()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/paho/mqtt/client.py", line 3522, in _create_socket_connection
    return socket.create_connection(addr, source_address=source, timeout=self._keepalive)
  File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
    raise err
  File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address
[DEBUG:2020-12-30 16:40:03,468] rhasspyserver_hermes: Connecting to localhost:12183 (retries: 0/10)
[DEBUG:2020-12-30 16:40:03,463] rhasspyserver_hermes: Starting core
[DEBUG:2020-12-30 16:40:03,404] rhasspyprofile.profile: Loading default profile settings from /usr/lib/rhasspy/rhasspy-profile/rhasspyprofile/profiles/defaults.json
[DEBUG:2020-12-30 16:40:03,386] rhasspyprofile.profile: Loading /profiles/en/profile.json
[DEBUG:2020-12-30 16:40:03,372] rhasspyprofile.profile: Loading /usr/lib/rhasspy/rhasspy-profile/rhasspyprofile/profiles/en/profile.json
[DEBUG:2020-12-30 16:40:02,782] rhasspyserver_hermes: Restarting Rhasspy

It seems like I am having some sort of MQTT error about using port 12183? Although it does seem to successfully connect to the MQTT broker after this error has occurred?

I tried switching to using External MQTT (using my MQTT broker from Home Assistant) however I seem unable to use an External Broker - Rhasspy errors and then locks me out of the web interface. I have to ssh in and edit the profile.json file manually back to default Internal settings to get back online.

I would be really gratetful for any suggestions or advice as to how I can get this working.

Thank you

I think I have the same Lav Mic but a TRS one and not TRRS so don’t need an adapter.

Tiny thing that seems quite good but I pulled off the sponge ‘dead cat’ and clip ring.

Pi Zero is boarderline depending on what you have running with load but many have them running successful.

As a tip to setting up any Pi create a file /etc/modprobe.d/alsa-base.conf

Mine currently is :-

options snd_usb_audio index=0
options snd_aloop index=1 pcm_substreams=2
options snd_bcm2835 index=2
options snd slots=snd-usb-audio,snd-aloop,snd-bcm2835

That will make your usb soundcard be index 0 and just my OCD but makes things cleaner and easier to set up.
You just set up the indexes and the slots will then re-order and yeah it is underscore for indexes and hyphen for slots just to confuse you.
The 2nd device is a loopback as I also use EC but can be omitted.

If you boot your pi with no audio hardware attached.

cat /proc/asound/modules will show you the default state so when you plugin what ever you have you can run again and find out what modules have been added.
/proc/asound/ is where and how alsa accesses and organises audio hardware on linux.

Before you run Rhasspy arecord -Dplughw:0 -r16000 -fS16_LE -c1 test.wav and copy that and play in audacity.
amixer controls
If your soundcard has AGC amixer cset numid=agc 1
You will just have to change agc to the index that control resides on.
alsamixer and f5 to get capture inputs and whack it up to max.

Again arecord test and listen

In fact here I knocked the gain down to -21db on one of those cheap white usb souncards.

sudo lsusb -vv

Bus 001 Device 005: ID 1b3f:2008 Generalplus Technology Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x1b3f Generalplus Technology Inc.
  idProduct          0x2008 
  bcdDevice            1.00
  iManufacturer           1 GeneralPlus
  iProduct                2 USB Audio Device
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x00fd
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0064
        bInCollection           2
        baInterfaceNr(0)        1
        baInterfaceNr(1)        2
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             4
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bNrChannels             1
        wChannelConfig     0x0001
          Left Front (L)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID               6
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               9
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      5 (SELECTOR_UNIT)
        bUnitID                 9
        bNrInPins               1
        baSourceID(0)           5
        iSelector               0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 6
        bSourceID               8
        bControlSize            1
        bmaControls(0)       0x01
          Mute Control
        bmaControls(1)       0x02
          Volume Control
        bmaControls(2)       0x02
          Volume Control
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 5
        bSourceID               4
        bControlSize            1
        bmaControls(0)       0x43
          Mute Control
          Volume Control
          Automatic Gain Control
        bmaControls(1)       0x00
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 7
        bSourceID               4
        bControlSize            1
        bmaControls(0)       0x03
          Mute Control
          Volume Control
        bmaControls(1)       0x00
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      4 (MIXER_UNIT)
        bUnitID                 8
        bNrInPins               2
        baSourceID(0)           1
        baSourceID(1)           7
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        bmControls(0)        0x00
        iMixer                  0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        44100
        tSamFreq[ 1]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x00c0  1x 192 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           2
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                14
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             1
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            2 Discrete
        tSamFreq[ 0]        44100
        tSamFreq[ 1]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0064  1x 100 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               2.01
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      41
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              32
Device Status:     0x0000
  (Bus Powered)

https://drive.google.com/open?id=1jW52NNn4T53JUxFNQEZlLdWQiXAUNLW7

Then if I select the voice part of the waveform without the nasty start click and go to effects in Audacity and select amplify it tells me I need 4.8db to normalise to 0db.

So I will up the gain to 25.5db (nearest +4.8db befor clipping) and I have set my mic up to what I expect loudest voice close field 0.3m and the rest is what ever the mic and AGC can provide.

In fact mine is not the same as I got a uni-directional from ebay but was a ‘does size matter’ comparison with my boya. The uni-directional are not a beam just cardinoid with some rear and side rejection that can help with echo and noise rejection that omni’s can not.

Which are the same price https://www.ebay.co.uk/itm/BOYA-BY-MM1-Shotgun-Microphone-3-5mm-TRS-TRRS-Output-For-Smartphone-Camera-DSLR/402621215738?

Prob with shopping can get the 1st mic much cheaper.

I think the Sabrent is a CM108-Chipset

I prefer the Pi3A+ as its only 10$ more but 10x what a Zero can do and for me the $15 vs $25 is a no brainer 10x the Ooomf for 1.66x the price is just such a good deal.