Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Update for newer Porcupine engines #2722

Merged
merged 4 commits into from
Jan 25, 2021

Conversation

forslund
Copy link
Collaborator

Description

This switches the module to use the pvporcupine library instead of the git clone. It updates the code to match the new signature of the Porcupine class initialization. It also switches to use the builtin module finding code which will make the hotword engine usable on Raspberry Pi units.

Should resolve #2720

This also does some minor cleanup of the Porcupine hotword module.

How to test

  • Install pvporcupine mycroft-pip install pvporcupine
  • Download the blueberry keyword file from here
    Create a hotword entry in your mycroft.conf and set the listener to use it.
...
  "listener": {
    "wake_word": "blueberry"
  },
  "hotwords": {
    "blueberry": {
      "module": "porcupine",
      "keyword_file_path": "PATH_TO_BLUEBERRY.ppn"
    }
  }

Contributor license agreement signed?

CLA [ Yes ]

@devops-mycroft devops-mycroft added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label Oct 15, 2020
@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@krisgesling krisgesling added Status: To be reviewed Concept accepted and PR has sufficient information for full review Type: Bug - quick Bug fixes that are quick to review and the implications of the change are clear and contained. labels Oct 15, 2020
@krisgesling
Copy link
Contributor

Hey I haven't dug into this yet but just gave it a quick test on a Mark II OTA (w respeaker), keeps failing and falling back to pocketsphinx:

2020-12-09 01:20:52.367 | INFO     | 17127 | mycroft.client.speech.hotword_factory:load_module:418 | Loading "blueberry" wake word via porcupine
2020-12-09 01:20:52.383 | ERROR    | 17127 | mycroft.client.speech.hotword_factory:initialize:437 | Could not create hotword. Falling back to default.
Traceback (most recent call last):
  File "/home/mycroft/mycroft-core/mycroft/client/speech/hotword_factory.py", line 426, in initialize
    instance = clazz(hotword, config, lang=lang)
  File "/home/mycroft/mycroft-core/mycroft/client/speech/hotword_factory.py", line 338, in __init__
    from pvporcupine.porcupine import Porcupine
  File "/home/mycroft/mycroft-core/.venv/lib/python3.8/site-packages/pvporcupine/__init__.py", line 13, in <module>
    from .util import *
  File "/home/mycroft/mycroft-core/.venv/lib/python3.8/site-packages/pvporcupine/util.py", line 54, in <module>
    _PV_SYSTEM, _PV_MACHINE = _pv_platform()
  File "/home/mycroft/mycroft-core/.venv/lib/python3.8/site-packages/pvporcupine/util.py", line 47, in _pv_platform
    pv_machine = _pv_linux_machine(platform.machine())
  File "/home/mycroft/mycroft-core/.venv/lib/python3.8/site-packages/pvporcupine/util.py", line 24, in _pv_linux_machine
    model_info = [x for x in cpu_info.split('\n') if 'model name' in x][0]
IndexError: list index out of range

I wonder if running Ubuntu 20.04 on a Pi is confusing it - but I've tried both the linux and raspberry pi variants of the ppn.

Did you hit this at all?

@krisgesling
Copy link
Contributor

Drafted an addition to docs for when we merge this too:
https://github.com/MycroftAI/documentation/tree/feature/porcupine-ww

@forslund
Copy link
Collaborator Author

forslund commented Dec 9, 2020

Did you run it on an aarch64 build or an armhf build of the Mark-2? It could be as you say or some change in the way cpu info is presented on python 3.8

@JarbasAl
Copy link
Contributor

JarbasAl commented Dec 9, 2020

shouldnt this be moved for the new plugin system?

@forslund
Copy link
Collaborator Author

forslund commented Dec 9, 2020

It really should I'm actually doing a plugin for this. But it shouldn't be broken in core either...

Will there be a release before 21.02 if not we might just as well drop this one entirely.

@forslund
Copy link
Collaborator Author

forslund commented Dec 9, 2020

Ok dug into this a bit. Likely something has changed between kernel versions or userspace versions in how the cpu info is reported the "model info" string that porcupine is looking for is not found in the output string

- Update the creation of Porcupine object
- Update the detection to accept >= 0 (index of detected hot word)
This is the same set of bindings as previously but packaged and
published on pypi

Picovoce library finder functions are used to determine the location of
libraries.
@JarbasAl
Copy link
Contributor

JarbasAl commented Dec 9, 2020

at least throw a deprecation warning saying this will move to a plugin?

maybe even link to it if it already exists

that way its begins being phased out, users are already being pointed to the needed changes. Also if this is currently broken doesnt that mean noone is using it so its safe to deprecate?

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@forslund
Copy link
Collaborator Author

That's a good idea @JarbasAI, I'll add that

@devops-mycroft
Copy link

Voight Kampff Integration Test Succeeded (Results)

@chrisl8
Copy link

chrisl8 commented Jan 24, 2021

FWIW: I use Porcupine, and it was broken after the Porcupine 1.9.0 release, and this PR fixes it for me. I look forward to this being merged. Thank you.

Copy link
Contributor

@krisgesling krisgesling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming this is functionally working @chrisl8

The code all looks good, so going to merge this now.

As mentioned above, it will get pulled out to a standalone plugin shortly.

@krisgesling krisgesling merged commit 73f0299 into MycroftAI:dev Jan 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) Status: To be reviewed Concept accepted and PR has sufficient information for full review Type: Bug - quick Bug fixes that are quick to review and the implications of the change are clear and contained.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot get Porcupine wakeword detection working with Raspberry-pi
5 participants