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

Conversation

alumae
Copy link

@alumae alumae commented May 24, 2019

Description

This PR adds support for the Porcupine wakeword engine, thus fixing issue #1491.

Porcupine is fast, very accurate and supports user-generated wakewords. That is, you can generate a wakeword listener model by just specifying an English text string.

The bad thing is that Porcupine is closed source and generated wake words are only valid for 30 days (but you can always use the provided optimizer to generate a new one).

How to test

On Linux:

Clone Porcupine into e.g. ~/.mycroft:

cd ~/.mycroft
git clone https://github.com/Picovoice/Porcupine.git

Generate a wake word file:

./Porcupine/tools/optimizer/linux/x86_64/pv_porcupine_optimizer \
    -r ./Porcupine/resources/optimizer_data -w "hey mycroft" -p linux -o .

In ~/.mycroft/mycroft.conf, set the "hey mycroft" wakeword section as follows:

"hey mycroft": {
    "module": "porcupine",
    "porcupine_path": "~/.mycroft/Porcupine",
    "keyword_file_path": "~/.mycroft/hey mycroft_linux.ppn"
},

Contributor license agreement signed?

CLA [ ] (Whether you have signed a CLA - Contributor Licensing Agreement

Requested to sign.

@pep8speaks
Copy link

pep8speaks commented May 24, 2019

Hello @alumae! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-05-24 20:45:52 UTC

@penrods penrods added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label May 25, 2019
@forslund
Copy link
Collaborator

forslund commented Jun 5, 2019

Hi, sorry for the delay on reviewing this. I will make time for it at the end of the week at the latest.

@forslund
Copy link
Collaborator

forslund commented Dec 8, 2019

Sorry this got lost in some reorganization madness. I had a quick look at it a couple of months ago but couldn't quite follow the instructions and now I took a deeper look and the issue seems to be that they've removed the possibility to create custom wakewords? the optimizer folder is removed and missing in older commits as well it seems. Does this still have value to include?

@forslund
Copy link
Collaborator

forslund commented Dec 8, 2019

But there are a bunch of pre-trained wakewords and this seems to be working fine.

@ChanceNCounter
Copy link
Contributor

https://github.com/Picovoice/Porcupine apparently

It looks like they went Apache and made some sort of webapp for training custom wakewords.

@forslund
Copy link
Collaborator

forslund commented Dec 8, 2019

Ah in the console thing. Ok then it's all good I guess :) (btw @ChanceNCounter do you ever sleep?)

@forslund
Copy link
Collaborator

Tested and seems to work just fine. Merging.

@forslund forslund merged commit 3315d98 into MycroftAI:dev Dec 12, 2019
@butteryak
Copy link

butteryak commented Oct 13, 2020

Trying to use Porcupine for wake word detection, and not having any success: As there is no way to create a custom wakeword as optimizer is no longer part of the porcupine package, I do see there is a way with the picovoice console tool to create custom wake word, but the free version only allows creation of wake for for x86 not ARM based machines....so trying to work with the existing models that are included with Procupine package. I have set mycroft.conf as this:

"listener": {
  "wake_word": "blueberry"
},

"hotwords": {
  "blueberry": {
    "module": "porcupine",
    "porcupine_path": "~/.mycroft/Porcupine",
    "keyword_file_path": "~/.mycroft/Porcupine/resources/keyword_files/raspberry-pi/blueberry_raspberry-pi.ppn"
    }
}

Porcupine wake word appears to be attempint to load, but having this error:

2020-10-13 18:03:22.296 | INFO     |  6577 | mycroft.client.speech.listener:create_wake_word_recognizer:328 | Creating wake word engine
2020-10-13 18:03:22.299 | INFO     |  6577 | mycroft.client.speech.listener:create_wake_word_recognizer:351 | Using hotword entry for blueberry
2020-10-13 18:03:22.302 | WARNING  |  6577 | mycroft.client.speech.listener:create_wake_word_recognizer:353 | Phonemes are missing falling back to listeners configuration
2020-10-13 18:03:22.305 | WARNING  |  6577 | mycroft.client.speech.listener:create_wake_word_recognizer:357 | Threshold is missing falling back to listeners configuration
2020-10-13 18:03:22.310 | INFO     |  6577 | mycroft.client.speech.hotword_factory:load_module:403 | Loading "blueberry" wake word via porcupine
2020-10-13 18:03:22.315 | INFO     |  6577 | mycroft.client.speech.hotword_factory:__init__:331 | Adding /home/pi/.mycroft/Porcupine/binding/python to Python path
2020-10-13 18:03:22.338 | INFO     |  6577 | mycroft.client.speech.hotword_factory:__init__:356 | Loading Porcupine using library path /home/pi/.mycroft/Porcupine/lib/linux/armv7l/libpv_porcupine.so and keyword paths ['/home/pi/.mycroft/Porcupine/resources/keyword_files/raspberry-pi/blueberry_raspberry-pi.ppn']
2020-10-13 18:03:22.341 | ERROR    |  6577 | mycroft.client.speech.hotword_factory:initialize:423 | Could not create hotword. Falling back to default.
Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/client/speech/hotword_factory.py", line 411, in initialize
    instance = clazz(hotword, config, lang=lang)
  File "/home/pi/mycroft-core/mycroft/client/speech/hotword_factory.py", line 361, in __init__
    sensitivities=sensitivities)
TypeError: __init__() got an unexpected keyword argument 'model_file_path'
2020-10-13 18:03:22.345 | INFO     |  6577 | mycroft.client.speech.hotword_factory:load_module:403 | Loading "blueberry" wake word via pocketsphinx
2020-10-13 18:03:22.475 | INFO     |  6577 | mycroft.client.speech.listener:create_wakeup_recognizer:365 | creating stand up word engine
2020-10-13 18:03:22.478 | INFO     |  6577 | mycroft.client.speech.hotword_factory:load_module:403 | Loading "wake up" wake word via pocketsphinx
2020-10-13 18:03:22.602 | INFO     |  6577 | __main__:on_ready:175 | Speech client is ready.

I saw the Phenome and Threshold warnings, so tried to set those in mycroft.conf, but it did not make any difference, I got exactly the same errors.

Interestingly enough, I ask mycroft what the listener is and it tells me it's "Porcupine" although any sound seems to trigger it, and it is not recogizing speech commands after trigger.

I"m noting that the library that is loaded is "Loading Porcupine using library path /home/pi/.mycroft/Porcupine/lib/linux/armv7l/libpv_porcupine.so " which could be an issue, as this is raspberry-pi and the Procupine package has a specific library for raspberry-pi. I tried adjusting the code in "hotword_factory.py" to use the raspberry pi library.

 library_path = join(
            porcupine_path, 'lib/raspberry-pi/arm11/libpv_porcupine.so')
        model_file_path = join(
            porcupine_path, 'lib/common/porcupine_params.pv')

but I get the same error. So, how to go about getting this setup on raspberry-pi using the included raspberry-pi wakewords?

@forslund
Copy link
Collaborator

forslund commented Oct 14, 2020

Hmm, they seem to have made some changes to the layout of the library (but only x86 was tried during tests since that was the only one publicly available for free trial at the time so I might have missed an issue here)...They've also released some new instructions for installation so might be worth looking over in general.

Edit: Will try it out here and see...

@forslund
Copy link
Collaborator

Did some tests during lunch and I think I got as far as you did, changed the path to match and then updated the Porcupine init so the arguments matched but no wakeword did just trigger repeatedly after that...will keep digging a bit later. Maybe open a separate issue for this?

@butteryak
Copy link

#2720 Opened a new issue. thanks for taking a look. I really like Porcupine, it's wakeword detection is great++ hope to get it working++ Will be of any help I can++

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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants