gia-guar / JARVIS-ChatGPT

A Conversational Assistant equipped with synthetic voices including J.A.R.V.I.S's. Powered by OpenAI and IBM Watson APIs and a Tacotron model for voice generation.
MIT License
384 stars 91 forks source link

Add support for Picovoice wakeword detection #4

Closed virtuallyaverage closed 1 year ago

virtuallyaverage commented 1 year ago

I had issues using Whisper to activate the Assistant, mainly when I tried out different wake words like "Jarvis" where it mislabeled the speech. To fix this I used PicoVoice Porcupine, which already has an impressively accurate model for the Jarvis wake-word, even picking it up clearly with decently loud worded music playing.

Picovoice runs entirely locally and is completely free to train new models for customized wake words and use. It does require the module pvporcupine to be installed. pip install pvporcupine But it is just a couple of MB, so install time shouldn't be too affected.

the main change is the block_until_wakeword function, which stops the loop until Porcupine is triggered. A note with Picovoice is that you can tell which word triggered the function, so it is possible that calling a different trigger word could be used to do different things. Implementations like user profiles, specialized functionality like local operations, web search, and more are possible with relative ease.

Other than that, I added a flag and environment variable to hold the PicoVoice key, as well as moved the block setting the key values to above the Assitant import calls. The last change is due to some errors I would get during startup in the Assistant file, due to the environment variables not being set before the importing of the class and it running the __init__ function.

Note: you have the .env file, but it is not activated or used in the actual program. This could be very useful.

I think I am going to work on a script that automates the installation of the process and sets the keys for users. That way there are clear and structured prompts.