Talking Pumpkin β Interactive AI Halloween Project Welcome to the Talking Pumpkin project! This Raspberry Pi-based setup lets you create a spooky interactive pumpkin that listens to visitors, talks back using AI-generated responses, and lights up with magical LED effects.
π Project Overview Uses a USB microphone to listen for voice input.
Sends audio to OpenAI Whisper API for speech-to-text transcription.
Sends transcription text to OpenAI GPT to generate a fun, spooky pumpkin reply.
Converts the reply text to speech using ElevenLabs TTS API.
Plays the spoken response through a connected speaker.
Controls two LEDs connected to the Pi's GPIO pins:
A glow LED that pulses softly to create a magical ambient effect.
A speech LED that flickers brightly synced with the speech audio playback.
π Hardware Requirements Component Notes Raspberry Pi 3B+ or 4 Main controller and AI processing USB Microphone Compact mic compatible with Pi Speaker USB or 3.5mm audio output LED (Glow) Connected to GPIO pin for pulsing effect LED (Speech) Connected to GPIO pin for flickering effect Resistors (220Ξ©) For current limiting on LEDs Jumper wires & breadboard For prototyping Power supply For Raspberry Pi and peripherals
π Repository Structure talking-pumpkin/ βββ audio/ β βββ prompts/ # Optional: pre-recorded prompts or chime sounds β βββ responses/ # Generated audio responses βββ scripts/ β βββ main.py # Main script: listens, generates reply, speaks, flickers LED β βββ led_controller.py # PWM-based LED pulsing and flickering β βββ utils.py # Audio recording, AI interaction, TTS, playback βββ requirements.txt # Python dependencies βββ setup.sh # Setup script for Raspberry Pi βββ .env.example # Sample environment variables for API keys βββ README.md # This file βββ wiring_diagram.png # Optional wiring diagram for LEDs and mic βοΈ Software Setup Clone this repository on your Raspberry Pi.
Create a Python virtual environment (recommended):
python3 -m venv venv source venv/bin/activate Install dependencies:
pip install --upgrade pip pip install -r requirements.txt Run the setup script to install system dependencies (optional but recommended):
sudo ./setup.sh Set up your environment variables:
Copy .env.example to .env and add your API keys for OpenAI and ElevenLabs.
Connect your hardware:
Wire LEDs to the specified GPIO pins (default 17 for glow LED, 27 for speech LED).
Connect microphone and speaker to Raspberry Pi.
π Running the Project From the scripts directory, run:
python main.py The system will prompt you to speak.
It will generate a spooky reply and play it.
LEDs will pulse and flicker according to the speech.
π Notes Ensure your microphone and speaker are properly configured and tested on the Pi.
Modify GPIO pins in main.py and led_controller.py as needed.
You can customize the AI personality by editing the system message in utils.py.
You can swap ElevenLabs TTS for other services by modifying utils.py.
π‘ Future Improvements Add voice activity detection (VAD) for smarter recording.
Use local speech-to-text or text-to-speech models for offline use.
Add a physical button or PIR sensor to activate the pumpkin.
Use multiple LEDs or addressable LED strips for richer lighting effects.
π License This project is open source and available under the MIT License.
πββοΈ Questions? Feel free to open issues or contact me!
Happy Halloween and enjoy your talking pumpkin! ππ»