Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

Porcupine not initializing #213

Open
moritzschaefer opened this issue Apr 24, 2020 · 6 comments
Open

Porcupine not initializing #213

moritzschaefer opened this issue Apr 24, 2020 · 6 comments

Comments

@moritzschaefer
Copy link

moritzschaefer commented Apr 24, 2020

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
Copy link
Contributor

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
Copy link

Tooa commented May 17, 2020

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

"porcupine.ppn": {

@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
Copy link
Contributor

@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
Copy link

Tooa commented May 18, 2020

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
Copy link
Contributor

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

machine_type = platform.machine()

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.

janekbettinger pushed a commit to janekbettinger/rhasspy that referenced this issue May 22, 2020
ignore that file might exist already,
change motivated by synesthesiam#213
@moritzschaefer
Copy link
Author

moritzschaefer commented May 22, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants