MagicMirror Module to Chat with ChatGPT
This module integrates ChatGPT into your MagicMirror setup, allowing you to interact with an AI assistant directly through your mirror.
- Customize the AI's personality.
- Speech-to-text integration using Google STT or Whisper API.
-
Clone the repository:
git clone https://github.com/magicmirror-sdmy/MMM-Chat.git cd MMM-Chat
-
Install dependencies:
pip3 install -r requirements.txt
-
Add credentials to the
MMM-Chat
directory (see below for details).
This module assumes the default installation path is /home/pi/MagicMirror
. If you are using a different location, update node_helper.js
with the correct directory.
You can change the personality of the AI by editing line 26 in MMM-Chat.js
. The default personality is set to "Drunk AI."
To make the AI sarcastic, use the following prompt:
"Your name is Marvin and you are a paranoid android that reluctantly answers questions with sarcastic responses."
Update the MMM-Chat.js
file with the desired prompt.
You will need:
- Google service account credentials.
- A billing account. Google offers a free quota; stay within this limit to avoid charges.
- Visit the Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to APIs & Services > Credentials.
- Click Create credentials and select Service account key.
- Choose a service account name and assign the Editor role.
- Go to the service account and click Add key.
- Select JSON as the key type and click Create.
The JSON key file will be downloaded. Rename it to credentials.json
and place it in the MMM-Chat
directory.
To verify the setup, run the following command:
python3 transcript.py
Speak into the microphone, and the transcription of your words should appear.
A script is provided for use with the Whisper API. However, in testing, Google STT offered better accuracy. If you'd like to use Whisper:
- Modify line 21 in
node_helper.js
to usewhisper.py
. - Install the OpenAI Python library:
pip3 install openai
Add the following lines to your config.js
:
{
module: "MMM-Chat",
config: {}
},
- Add a configuration option in
config.js
to support different AI personalities through prompts.