Smart Glasses with Proactive Speech Recognition, Context Awareness, and Real-Time Answer Generation
- Live audio capture from dual BLE-connected G1 smart glasses
- Speech-to-text using
whisper - Context recognition using lightweight NLP (
distilbert-base) - OpenAI GPT-4o API integration (o4-mini)
- Local caching of answers
- Fallback responses if the network/API fails
- Visual display to both left and right arms of G1
Install dependencies:
pip install openai
# And ensure these are present or mocked in testing
# bluetooth_ble, lc3_decoder, whisper, nlp_modelGet your API key from https://platform.openai.com/.
Set the key in your environment:
Linux/macOS:
export OPENAI_API_KEY='your-api-key-here'Windows PowerShell:
$env:OPENAI_API_KEY='your-api-key-here'- BLE mic on right arm is activated and starts capturing audio.
- Audio is received as LC3 packets, decoded into raw audio.
- Whisper transcribes speech to text.
- NLP model detects user intent (e.g., a question).
- If confidence is high, it checks local cache for a matching question.
- If no match, it sends a prompt to OpenAI's
gpt-4oand caches the response. - Answer is displayed on both arms of the G1 glasses.
G1-Proactive-AI/
├── proactive_ai.py # Main logic file
├── cache/ # Auto-generated cache for question/answer pairs
└── README.md # You're reading it
👓 User says: "What is AI?"
🤖 G1 sends: "User asked: What is AI? \n Provide a helpful, concise response."
✅ G1 displays: "AI is the simulation of human intelligence by machines."
If OpenAI API call fails (e.g., no internet):
- G1 uses a fallback message:
"Sorry, I couldn't get a full answer right now. Here's what I understood: {topic}"
- Integrated OpenAI
gpt-4oAPI (Tiny variant for smart devices) - Cached answers in
cache/using MD5 hashes of question prompts - Added robust fallback logic to keep UX consistent when offline
- Add offline model support for disconnected mode
- TTL (expiration) support for cache files
- Multilingual display integration