Wake word (porcupine) help is needed

Initially, apologies for poor English language skills.

The device is a Raspberry Pi 3 Model B + and a Docker, Rhasspy version 2.5.8.

I’m trying to enable the porcupine wake word -service but it doesn’t work. If I activate it, save settings and click the “refresh” button next to the “Available Keywords” field, the error message “TimeoutError” will appear. Nothing can be selected in the “Available Keywords” field.

Where is the “porcupine” folder located? I can’t find that folder anywhere.

On another PC machine the porcupine works normally but on the Raspberry does not.
Any ideas on what to do?

The porcupine folder should be created in your profiles folder.
This is dependent on your setup. Eg. for docker it’s dependent on the mapping

I’ve managed to put the files into the subdirectory of my profile folder but still get the timeout error.
Do I need to give docker more permissions or how can I debug this issue?

Thanks for the answer. I did the installation with this guide:

Should the porcupine folder then be in the following location: ~/.config/rhasspy/profiles/en?
The folder cannot be found in my installation.

When you start the docker image in console mode then you probably see something like I do right?
Seems like we’re missing the library for it?

1 Like

I seem to be having the same issue.

I just wiped my only instance of rhasspy but to install porcupine its pip3 install pvporcupine

Needs to be run in the container so

docker exec -it <container name> /bin/bash

Maybe that will fix from a currently blind perspective but may give clues to why porcupine is missing.

I do observe exactly the same issue with Rhasspy on an RPI3 run via Docker.
Trying to install pvporcupine via PIP3 results in various other errors, but I don’t think that this should be necessary, as the file actually exists:

root@13348ff9992b:/# ls -lihsa  /usr/lib/rhasspy/rhasspy-wake-porcupine-hermes/rhasspywake_porcupine_hermes/porcupine/lib/linux/x86_64/libpv_porcupine.so
776099 72K -rwxrwxr-x 1 root root 71K Sep 20 15:22 /usr/lib/rhasspy/rhasspy-wake-porcupine-hermes/rhasspywake_porcupine_hermes/porcupine/lib/linux/x86_64/libpv_porcupine.so

BUT shouldn’t the following file be used instead?

/usr/lib/rhasspy/rhasspy-wake-porcupine-hermes/rhasspywake_porcupine_hermes/porcupine/lib/raspberry-pi/cortex-a53/libpv_porcupine.so

That exists in the docker image as well. So my assumption is that there is some information about the hardware platform missing or not correctly detected.

1 Like

@synesthesiam any ideas?

The problem occurred when Rhasspy was installed on an Ubuntu 20.04 64-bit server platform. I started everything from scratch and installed Raspberry Pi OS Lite 32 bit, Docker and Rhasspy. Now Porcupine works. Still no porcupine folder can be found anywhere but the main thing is that it works. Could the problem be due to the 64-bit operating system?

Is that what you think it is if not 32bit the install presumes x86?

Can confirm that I run that on an Ubuntu 20.04 64-bit. On the same OS on my regular desktop it all works. There is also no porcupine folder. But I don’t think it is needed as everything is baked into the docker image. Only if you extend it you might have to put it into your profiles porcupine folder.

Some progress in my analysis that I’d like to share.

In /usr/lib/rhasspy/rhasspy-wake-porcupine-hermes/rhasspywake_porcupine_hermes/__main__.py the following code is used to build the directory where to search for the files based on the machine architecture.

machine = platform.machine()

if args.keyword_dir:
    args.keyword_dir = [Path(d) for d in args.keyword_dir]

# Add embedded keywords too
keyword_base = _DIR / "porcupine" / "resources" / "keyword_files"

if machine in ["armv6l", "armv7l", "armv8"]:
    # Raspberry Pi
    args.keyword_dir.append(keyword_base / "raspberrypi")
else:
    # Desktop/server
    args.keyword_dir.append(keyword_base / "linux")

The thing is, that

python -c 'import platform; print(platform.machine())'

on a Ubuntu 20.04 64-bit system returns aarch64, which is not mapped to raspberrypi in the above if-clause.

UPDATE: Further down on line 110 in main.py there is another check against the machine type:

  elif machine in ["armv7l", "armv8"]:
        # Pi 2 uses Cortex A7
        # Pi 3 uses Cortex A53
        # Pi 4 uses Cortex A72
        cpu_model = guess_cpu_model()
        _LOGGER.debug("Guessing you have an ARM %s", cpu_model)
        lib_dir = os.path.join(lib_dir, "raspberry-pi", str(cpu_model.value))

I added aarch64 to both spots which does built the right directories, BUT then you get this error:

OSError: /usr/lib/rhasspy/rhasspy-wake-porcupine-hermes/rhasspywake_porcupine_hermes/porcupine/lib/raspberry-pi/cortex-a53/libpv_porcupine.so: wrong ELF class: ELFCLASS32

Is it possible that it is not intended to run porcupine on a 64-bit OS on ARM architecture?

1 Like

I can confirm that the wake word is not working on my Odroid (arm 64-bit) installed via Docker (Home Assistant Add-On). On my previous device, an RPi 3, everything worked as expected.

I found some additional errors in my log, maybe they are helpful in some ways…

2021-01-14 21:04:58,951 INFO spawned: 'wake_word' with pid 791
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/rhasspy/rhasspy-wake-porcupine-hermes/rhasspywake_porcupine_hermes/__main__.py", line 15, in <module>
    import pvporcupine
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/pvporcupine/__init__.py", line 13, in <module>
    from .util import *
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/pvporcupine/util.py", line 54, in <module>
    _PV_SYSTEM, _PV_MACHINE = _pv_platform()
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/pvporcupine/util.py", line 47, in _pv_platform
    pv_machine = _pv_linux_machine(platform.machine())
  File "/usr/lib/rhasspy/.venv/lib/python3.7/site-packages/pvporcupine/util.py", line 23, in _pv_linux_machine
    hardware_info = [x for x in cpu_info.split('\n') if 'Hardware' in x][0]
IndexError: list index out of range
2021-01-14 21:04:59,517 INFO exited: wake_word (exit status 1; not expected)

Hi @dweuthen, thank you for your analysis. As luck would have it, I’ll be upgrading to porcupine v1.9 in Rhasspy 2.5.9. Additionally, I’m switching to using the pvporcupine Python package, which will (hopefully) do all the right things with platform detection!