An AI companion for Leia that uses wake word detection to enable voice-activated interactions.
LeAI Companion uses Picovoice's Porcupine wake word detection library to listen for specific keywords, allowing for hands-free activation of your AI companion. When activated, it uses speech recognition to understand your commands and communicates with Google's Gemini AI to provide intelligent responses.
- Python 3.7 or later
- A microphone connected to your computer
- Picovoice Access Key (get it from Picovoice Console)
- Google API Key (get it from Google AI Studio)
-
Clone this repository:
git clone [repository-url] cd leai_companion -
Create and activate a virtual environment:
# Windows python -m venv venv .\venv\Scripts\activate # Linux/MacOS python3 -m venv venv source venv/bin/activate
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.envfile in the project root and add your API keys:PICOVOICE_ACCESS_KEY=your_picovoice_key_here GOOGLE_API_KEY=your_google_api_key_here
-
Ensure your virtual environment is activated:
# Windows .\venv\Scripts\activate # Linux/MacOS source venv/bin/activate
-
Run the main script:
python src/wake_word_detector_cli.py
-
The program will start listening for wake words. By default, it listens for configured wake words that activate your AI companion.
-
To stop the program, press Ctrl+C.
The companion uses speech recognition to convert your voice into text. This enables natural voice interactions with the AI assistant. The system automatically starts listening for your voice input after detecting the wake word.
To ensure optimal speech recognition:
- Speak clearly and at a normal pace
- Use a good quality microphone
- Minimize background noise
To run the speech-to-text example:
python src/speech_to_text.py --model vosk-model-small-en-us-0.15Experimenting with cloud STT, seems of decent quality and speed.
To run the Google Cloud speech-to-text example:
python src/google_cloud_speech_cli.pyThe companion runs a wake word recognition server that launches speech recognition when activated and uses the Gemini streaming API to communicate. It streams the recognized words to Gemini and streams the AI's responses back to you in real-time.
To run the AI companion:
python src/talk_to_ai.py --wake_keyword bumblebeeThe companion will:
- Listen for the wake word ("bumblebee" by default)
- When the wake word is detected, start listening for your command
- Convert your speech to text
- Send your command to Gemini AI
- Stream Gemini's response back to you
- Continue to listen for further commands until you stop the program
This project uses Picovoice's Porcupine library, which requires a valid access key. See Picovoice's licensing terms for more information.