This project is designed to provide a voice-activated interface to ChatGPT using Python. The system listens for a wake word ("hey chatgpt"), opens Firefox, logs into ChatGPT (if necessary), and inputs a question automatically.
- Wake Word Detection: Uses Porcupine for efficient, offline wake word detection.
- Browser Automation: Automates login and interaction with ChatGPT using Selenium and Firefox.
- Automatic Question Submission: Inputs a predefined question and sends it to ChatGPT.
- Prerequisites
- Installation
- How It Works
- Running the System
- Backend Deployment
- Customization
- Troubleshooting
- License
Before you begin, make sure you have the following installed on your system:
- Python 3.x
- Firefox browser
- Geckodriver for Selenium (add it to your system's PATH)
-
Clone the repository:
git clone https://github.com/your-username/voice-chatgpt-automation.git cd voice-chatgpt-automation -
Install dependencies using
pip:pip install -r requirements.txt
-
Porcupine Setup:
- Download Porcupine wake word detection models from Picovoice and place the model in your working directory.
-
Geckodriver:
- Download Geckodriver and ensure it's in your system PATH, or specify its path in the script.
The system is divided into two parts:
-
Wake Word Listener (
listener.py): Continuously listens for the wake word ("hey chatgpt") using Porcupine. When the wake word is detected, it triggers the second script. -
ChatGPT Interaction (
chatgpt_interaction.py): Opens Firefox using Selenium, checks if you're logged into ChatGPT, and logs in if not. It then sends a predefined question to ChatGPT and waits for the response.
-
Configure Credentials: Edit
chatgpt_interaction.pyand replaceyour-email@example.comandyour-passwordwith your ChatGPT login credentials. -
Run the Listener:
python listener.py
This will start the system and begin listening for the wake word. Once detected, it will launch the ChatGPT interaction process automatically.
If you want the system to run as a backend service and continue listening for the wake word without requiring manual execution, you can deploy the system as a background process or service.
- Open Task Scheduler.
- Create a new task that runs
python listener.pyon system startup. - Set the task to run in the background with high privileges.
- Ensure the task is configured to start even if the user is not logged in.
-
Create a systemd service file
/etc/systemd/system/voice_chatgpt.service:[Unit] Description=Voice ChatGPT Automation Listener [Service] ExecStart=/usr/bin/python3 /path/to/your/listener.py Restart=always [Install] WantedBy=multi-user.target
-
Start and enable the service:
sudo systemctl enable voice_chatgpt.service sudo systemctl start voice_chatgpt.service -
Alternatively, use a cron job:
@reboot /usr/bin/python3 /path/to/your/listener.py
This will ensure that the listener runs in the background whenever the system is booted.
-
Wake Word: To change the wake word, edit
listener.pyand modify this line:porcupine.create(keywords=["hey chatgpt"])
You can change "hey chatgpt" to any other supported keyword or custom wake word using Picovoice’s platform.
-
Predefined Question: In
chatgpt_interaction.py, modify this section to send a different question:chat_input.send_keys("What is the capital of France?")
-
Selenium Customization:
- You can modify the
chatgpt_interaction.pyscript to handle different interactions with the ChatGPT page, including submitting multiple queries or interacting with other elements.
- You can modify the
-
Porcupine Not Detecting Wake Word: Ensure that the microphone is correctly set up and working. You can use system utilities to test if the microphone is receiving input.
-
Selenium Not Opening Firefox:
- Check that the correct version of
geckodriveris installed and it matches the version of Firefox you have. - Ensure
geckodriveris added to your system’s PATH.
- Check that the correct version of
-
ChatGPT Login Issues:
- Ensure that you’re using the correct email and password in
chatgpt_interaction.py. - If there are additional login steps (such as CAPTCHA or multi-factor authentication), manual intervention may be required the first time.
- Ensure that you’re using the correct email and password in
This project is licensed under the MIT License. See the LICENSE file for details.