A voice-activated assistant module for MagicMirror² using Porcupine for wake word detection, OpenAI's Whisper for speech recognition, and GPT for natural language processing.
- Wake word detection using Porcupine
- Speech-to-text using OpenAI's Whisper API
- Natural language processing using GPT-4o-mini
- Text-to-speech using OpenAI's TTS API
- Conversation mode for continuous interaction
- Standby mode for power efficiency and privacy
Before installing this module, make sure you have the following:
- A working installation of MagicMirror²
- Node.js version 12 or later
- npm (Node Package Manager)
- A microphone connected to your MagicMirror device
- Speakers or an audio output device
- An OpenAI API key (you can obtain one by signing up at OpenAI)
- A Picovoice Porcupine access key (sign up at Picovoice Console)
-
Navigate to your MagicMirror's
modules
folder:cd ~/MagicMirror/modules/
-
Clone this repository:
git clone https://github.com/LeonardSEO/MMM-VoiceCompanion.git
-
Change to the newly created module directory:
cd MMM-VoiceCompanion
-
Install the dependencies:
npm install
-
Add the module to your
config/config.js
file in the MagicMirror directory:{ module: "MMM-VoiceCompanion", config: { wakeWord: "HEY_GOOGLE", porcupineAccessKey: "your-porcupine-access-key-here", openAiKey: "your-openai-api-key-here", language: "en", voiceId: "echo", conversationTimeout: 120000, standbyTimeout: 30000 } }
Replace
"your-porcupine-access-key-here"
and"your-openai-api-key-here"
with your actual API keys. -
Restart your MagicMirror:
pm2 restart MagicMirror
Option | Description |
---|---|
wakeWord | The wake word to activate the voice assistant (must be one of the BuiltinKeyword values) |
porcupineAccessKey | Your Porcupine access key |
openAiKey | Your OpenAI API key |
language | The language code for speech recognition (default: "en") |
voiceId | The voice ID for text-to-speech (default: "echo") |
conversationTimeout | Time in milliseconds before conversation mode ends (default: 120000) |
standbyTimeout | Time in milliseconds of inactivity before entering standby mode (default: 30000) |
The following wake words are available as built-in keywords for Porcupine:
- ALEXA
- AMERICANO
- BLUEBERRY
- BUMBLEBEE
- COMPUTER
- GRAPEFRUIT
- GRASSHOPPER
- HEY_GOOGLE
- HEY_SIRI
- JARVIS
- OK_GOOGLE
- PICOVOICE
- PORCUPINE
- TERMINATOR
Choose one of these values for the wakeWord
configuration option.
- Say the configured wake word (e.g., "Hey Google") to activate the voice assistant.
- The module will enter conversation mode, indicated by an overlay on the screen.
- Speak your query or command. The assistant will process your speech and respond both visually and audibly.
- Continue the conversation without repeating the wake word. The module will remain in conversation mode for the duration specified by
conversationTimeout
. - If there's no interaction for the duration specified by
standbyTimeout
, the module will enter standby mode. - To start a new conversation, say the wake word again.
To update the MMM-VoiceCompanion module to the latest version, follow these steps:
-
Navigate to your MagicMirror's
modules
folder:cd ~/MagicMirror/modules/MMM-VoiceCompanion
-
Pull the latest changes from the repository:
git pull
-
Update the module's dependencies:
npm update
-
Restart your MagicMirror to apply the updates:
pm2 restart MagicMirror
This will ensure your module is up-to-date with the latest features and bug fixes.
This module uses ESLint to ensure code quality. To run the linter:
npm run lint
To automatically fix linting issues:
npm run lint:fix
If you encounter any issues:
-
Check the MagicMirror logs for any error messages:
pm2 logs MagicMirror
-
Ensure your microphone and speakers are properly connected and functioning.
-
Verify that your Porcupine and OpenAI API keys are correct and have the necessary permissions.
-
Make sure you have a stable internet connection, as this module requires online access for API calls.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- MagicMirror² for the amazing smart mirror platform
- Picovoice for the Porcupine wake word detection
- OpenAI for the powerful GPT and Whisper APIs