synesthesiam / rhasspy

Rhasspy voice assistant for offline home automation
https://rhasspy.readthedocs.io
MIT License
950 stars 101 forks source link

Porcupine not initializing #213

Open moritzschaefer opened 4 years ago

moritzschaefer commented 4 years ago

On my RPi 3B+, I don't get Porcupine to work. This is my config:

{
    "handle": {
        "system": "hass"
    },
    "home_assistant": {
        "api_password": "*****",
        "url": "http://192.168.178.117:8123"
    },
    "microphone": {
        "pyaudio": {
            "device": "1"
        }
    },
    "wake": {
        "system": "porcupine"
    }
}

Here is the error output of rhasspy:

rhasspy_1 | ERROR:PorcupineWakeListener:loading wake handle rhasspy_1 | [2020-04-24 12:09:30,740] 192.168.178.92:53144 POST /api/listen-for-command 1.1 200 474 7560146 rhasspy_1 | Traceback (most recent call last): rhasspy_1 | File "/usr/share/rhasspy/rhasspy/wake.py", line 852, in in_started rhasspy_1 | self.load_handle() rhasspy_1 | File "/usr/share/rhasspy/rhasspy/wake.py", line 937, in load_handle rhasspy_1 | sensitivities=self.sensitivities, rhasspy_1 | File "/usr/share/rhasspy/porcupine.py", line 117, in init rhasspy_1 | raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]('initialization failed') rhasspy_1 | OSError: initialization failed

Is there a way to get some debug output from porcupine directly?

Of note, snowboy works!

janekbettinger commented 4 years ago

I faced the same issue and got it working (again) by using the library and ppn files from https://github.com/Picovoice/porcupine instead of the ones shipped with Rhasspy 2.4.20.

My profile.json now contains:

{
    "wake": {
        "porcupine": {
            "keyword_path": "<original-porcupine>/resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn",
            "library_path": "<original-porcupine>/lib/raspberry-pi/cortex-a72/libpv_porcupine.so",
            "model_path": "<original-porcupine>/lib/common/porcupine_params.pv"

        },
        "system": "porcupine"
    }
}

See https://github.com/Picovoice/porcupine/blob/master/lib/README.md for the correct library file and https://github.com/Picovoice/porcupine/tree/master/resources/keyword_files/raspberry-pi for the keyword files available.

Tooa commented 4 years ago

The files shipped with 2.4.20 are actually the ones from Picovoice/porcupine:

https://github.com/synesthesiam/rhasspy/blob/de0824e49a09452f422f90b03fb3e8fdd8488e40/profiles/defaults.json#L338

@kroka Can you see any problem with the files linked in the default.json file? The only thing I see is that we are not using the libpv_porcupine.so from cortex-a72 which would be optimized for rpi 4.

cortex-a53 is tuned for 3 and 3 B+. cortex-a72 is tuned for 4.

janekbettinger commented 4 years ago

@Tooa, I have a Raspberry Pi 4 (with Rhasspy 2.4.20) and the armv7l / aarch64 files linked in the defaults.json work for me. I've manually downloaded them. The default files (if I do not configure anything) shipped with Rhasspy lead to the error given in the initial post above.

Since working files are already listed in the defaults.json: does Rhasspy choose the wrong architecture in my case? Actually I do not exactly know what PPN file I have in .config/rhasspy/profiles/de/porcupine/ as a diff shows a difference (binary) to the just downloaded x86_64 and armv7l/aarch64 file.

Tooa commented 4 years ago

Thanks for reaching back.

I have a Raspberry Pi 4 (with Rhasspy 2.4.20) and the armv7l / aarch64 files linked in the defaults.json work for me.

From what I understand is that Rhasspy downloads the files referenced in defaults.json. I guess, something is broken with the automatic download then because the files work for you when downloaded by hand.

Looks like this function is responsible for the download of the entries from the defaults.json file. The function does log a few things. Do you still have the log from the failing case i.e. the download of the suspicious wrong files?

janekbettinger commented 4 years ago

Hi @Tooa,

I've triggered a fresh download via the API (POST "<rhasspy>/api/download-profile?delete=true), but had to manually delete the Porcupine files as they have not been deleted by the delete option:

May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Deleting download cache at /home/pi/.config/rhasspy/profiles/de/download
May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Using cached /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine_params.pv for porcupine/porcupine_params.pv
May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Using cached /home/pi/.config/rhasspy/profiles/de/porcupine/libpv_porcupine.so for porcupine/libpv_porcupine.so
May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Using cached /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine.ppn for porcupine/porcupine.ppn

But now I finally have the correct files:

May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Deleting download cache at /home/pi/.config/rhasspy/profiles/de/download
May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloading https://github.com/Picovoice/porcupine/raw/v1.7/lib/common/porcupine_params.pv to /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine_params.pv
May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloading https://github.com/Picovoice/porcupine/raw/v1.7/lib/raspberry-pi/cortex-a53/libpv_porcupine.so to /home/pi/.config/rhasspy/profiles/de/porcupine/libpv_porcupine.so
May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloading https://github.com/Picovoice/porcupine/raw/v1.7/resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn to /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine.ppn
May 22 13:08:26 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloaded /home/pi/.config/rhasspy/profiles/de/porcupine/libpv_porcupine.so
May 22 13:08:26 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloaded /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine.ppn
May 22 13:08:27 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloaded /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine_params.pv

It also detected the correct architecture armv7l for my Pi via https://github.com/synesthesiam/rhasspy/blob/3c53cd0236a397a4069f84d12766e786cec3cb89/rhasspy/core.py#L550

I cannot exactly say why I had wrong files initially. It could be a leftover from my initial Rhasspy installation for which I used the Docker image. In the meanwhile I've switched to the plain Python venv.

@moritzschaefer how is it working for you? From my side we could close this issue.

moritzschaefer commented 4 years ago

Yes, we can also close from my side. I am at the moment fighting with Raspberry Pi4 and NixOS and would reopen if I encounter the same problem on the new system.

On Fri, 22 May 2020 at 14:22, kroka notifications@github.com wrote:

Hi @Tooa https://github.com/Tooa,

I've triggered a fresh download via the API (POST "/api/download-profile?delete=true), but had to manually delete the Porcupine files as they have not been deleted by the delete option:

May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Deleting download cache at /home/pi/.config/rhasspy/profiles/de/download May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Using cached /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine_params.pv for porcupine/porcupine_params.pv May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Using cached /home/pi/.config/rhasspy/profiles/de/porcupine/libpv_porcupine.so for porcupine/libpv_porcupine.so May 22 12:47:29 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Using cached /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine.ppn for porcupine/porcupine.ppn

But now I finally have the correct files:

May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Deleting download cache at /home/pi/.config/rhasspy/profiles/de/download May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloading https://github.com/Picovoice/porcupine/raw/v1.7/lib/common/porcupine_params.pv to /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine_params.pv May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloading https://github.com/Picovoice/porcupine/raw/v1.7/lib/raspberry-pi/cortex-a53/libpv_porcupine.so to /home/pi/.config/rhasspy/profiles/de/porcupine/libpv_porcupine.so May 22 13:08:25 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloading https://github.com/Picovoice/porcupine/raw/v1.7/resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn to /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine.ppn May 22 13:08:26 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloaded /home/pi/.config/rhasspy/profiles/de/porcupine/libpv_porcupine.so May 22 13:08:26 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloaded /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine.ppn May 22 13:08:27 raspberrypi rhasspy[4296]: DEBUG:RhasspyCore:Downloaded /home/pi/.config/rhasspy/profiles/de/porcupine/porcupine_params.pv

It also detected the correct architecture armv7l for my Pi via https://github.com/synesthesiam/rhasspy/blob/3c53cd0236a397a4069f84d12766e786cec3cb89/rhasspy/core.py#L550

I cannot exactly say why I had wrong files initially. It could be a leftover from my initial Rhasspy installation for which I used the Docker image. In the meanwhile I've switched to the plain Python venv.

@moritzschaefer https://github.com/moritzschaefer how is it working for you? From my side we could close this issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/synesthesiam/rhasspy/issues/213#issuecomment-632664518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUWXLCU6UP6J5FQVT3TBSDRSZVA3ANCNFSM4MQBUMTQ .

--

Moritz Schäfer

ETH Zurich Department of Biology

Otto-Stern-Weg 7

8093 Zürich, Switzerland

*moritz.schaefer@biol.ethz.ch moritz.schaefer@biol.ethz.ch* http://www.bsse.ethz.ch