Using External MQTT breaks microphone

I have rhasspy running on one pi, and home assistant on another. I have a matrix microphone on the rhasspy. It will wake and send an event to HA so long as I’m using the internal MQTT, but if I set it to use the mosquitto broker on HA, rhasspy resets PyAudio to default device and will not recognize any other device. Using the external broker is needed for many actions in HA; the broker is working there. Any help is appreciated.

Did you ever figure this out? I’m having the same issue and have been tinkering with it for a week but to no avail.

I’m using a Pi Zero with 4-mic hat. I can set-up everything on the satellite (wake-word, tts, sst, etc.) but as soon as I add External MQTT the microphone disappears from arecord.

Can anyone help!?

Oh wow, I was just coming to post an issue where I couldn’t get audio devices. I was following Tutorial: Add Rhasspy local voice control to Home Assistant - Using a Raspberry Pi Zero with reSpeaker 2-mic HAT - #4 by donburch tutorial, and have MQTT set to External for my HA instance, and just keep not being able to refresh the Audio Devices to ensure the right one is selected.

I do notice, on the terminal output, I think the problem might be an MQTT issue. It looks as if, when requesting audio devices, it’s actually trying to get MQTT to refresh/update the available devices.

For example, I’ve gotten through Part 2, number 23. In the console, I see

[DEBUG:2023-07-13 07:48:15,082] rhasspyserver_hermes: -> AudioGetDevices(modes=[<AudioDeviceMode.INPUT: 'input'>], site_id='default', id='33dab746-7634-4c74-89ed-d24de840c768', test=False)
[DEBUG:2023-07-13 07:48:15,135] rhasspyserver_hermes: Publishing 102 bytes(s) to rhasspy/audioServer/getDevices
Traceback (most recent call last):
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/rhasspy/rhasspy-speakers-cli-hermes/rhasspyspeakers_cli_hermes/__init__.py", line 13, in <module>
    import soundfile
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/site-packages/soundfile.py", line 16, in <module>
    from ctypes.util import find_library as _find_library
  File "/usr/lib/rhasspy/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: libffi.so.6: cannot open shared object file: No such file or directory

However, I think the key is the libffi.so.6 not being able to be found.

Step 13 says for Bullseye. Which, as it happens, is the latest version of Raspbian that I have running, Debian 11.7, which is Bullseye. After installing it via sudo apt-get install libffi6, everything seems to be working now. At least for me.

Startup is super slow, but it’s an RPi Zero W, so not unexpected that it’s so slow. And I’ve had to hit Ctl-C and start the instance back up a few times, but I suspect that’s due to the slowness of the device.

But anyway, try installing libffi6 if you’re on Bullseye.

Yes, libffi.so.6 has been rasied as an issue before. Are you using the 32-bit or 64-bit version of Raspbian ? From memory libffi6 is not included in the 64-bit version (and you probably aren’t using programs > 4Gb on a RasPi Zero anyway), so can you try with the 32-bit Raspbian ?

FWIW, my setup is :

  • Home Assistant with Rhasspy Assistant Addon - now in a VM running on an old PC under proxmox. IP address is 192.168.1.98. No changes were necessary when I transferred from running HA on a RasPi 4
  • RasPi 3A with reSpeaker 4-mic HAT
  • RasPi Zero with reSpeaker 2-mic HAT
  • RasPi 3B with USB microphone

I use HA’s Addon Mosquitto Broker, and created a new user “rhasspy” in HA, thinking it might help debugging later (it didn’t).

This is the Rhasspy profile from my RasPi Zero satellite (sat-0):

{
    "intent": {
        "system": "hermes"
    },
    "microphone": {
        "arecord": {
            "device": "plughw:CARD=seeed2micvoicec,DEV=0",
            "udp_audio_port": "12203"
        },
        "pyaudio": {
            "device": "0",
            "siteId": "sat-0",
            "udp_audio_port": "12203"
        },
        "system": "arecord"
    },
    "mqtt": {
        "enabled": "true",
        "host": "192.168.1.98",
        "password": "redacted",
        "port": "1883",
        "site_id": "sat-0",
        "username": "rhasspy"
    },
    "sounds": {
        "aplay": {
            "device": "plughw:CARD=seeed2micvoicec,DEV=0",
            "volume": "0.8"
        },
        "system": "aplay"
    },
    "speech_to_text": {
        "system": "hermes"
    },
    "text_to_speech": {
        "system": "hermes"
    },
    "wake": {
        "porcupine": {
            "keyword_path": "porcupine_raspberry-pi.ppn",
            "sensitivity": "0.3",
            "udp_audio": "12203"
        },
        "system": "porcupine"
    }
}

libffi.so.6 = Buster / libffi7 = Bullseye both contains 32/64 bit but different distro versions contain different versions.