#!/bin/bash # # Porcupine (Picovoice) Setup Script # AI Now Inc - Del Mar Demo Unit # # This script helps you set up Porcupine for better hotword detection # set -e # Colors GREEN='\033[0;32m' BLUE='\033[1;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" echo -e "${BLUE}" echo "==========================================" echo " 🎤 Porcupine Setup - AI Now Inc" echo "==========================================" echo -e "${NC}" echo "" # Check if virtual environment exists if [ ! -d "venv" ]; then echo -e "${RED}✗ Virtual environment not found!${NC}" echo "" echo "Please run the installer first:" echo " sudo ./install.sh" echo "" echo "Or create the virtual environment manually:" echo " python3 -m venv venv" echo " source venv/bin/activate" echo " pip install -r requirements.txt" exit 1 fi # Activate virtual environment echo "Activating virtual environment..." source venv/bin/activate echo -e "${GREEN}✓ Virtual environment activated${NC}" echo "" echo "Step 1: Get Your API Key" echo "━━━━━━━━━━━━━━━━━━━━━━━━" echo "" echo "1. Open your browser and go to:" echo -e " ${BLUE}https://console.picovoice.ai/${NC}" echo "" echo "2. Sign up for a free account (if you don't have one)" echo "" echo "3. Copy your **Access Key** (it looks like: xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)" echo "" # Prompt for API key echo -e "${YELLOW}Enter your Picovoice Access Key (or press 'q' to quit):${NC}" read -p "> " api_key if [ "$api_key" == "q" ] || [ "$api_key" == "Q" ]; then echo -e "${YELLOW}Setup cancelled.${NC}" exit 0 fi if [ -z "$api_key" ]; then echo -e "${RED}✗ No API key provided. Setup cancelled.${NC}" exit 1 fi echo "" echo -e "${BLUE}Step 2: Installing Porcupine...${NC}" echo "" # Install pvporcupine with the API key if PICOVOICE_API_KEY="$api_key" pip install pvporcupine; then echo -e "${GREEN}✓ Porcupine installed successfully!${NC}" else echo -e "${RED}✗ Failed to install Porcupine${NC}" echo "Make sure you have a valid API key and internet connection." exit 1 fi echo "" echo -e "${BLUE}Step 3: Saving Configuration...${NC}" echo "" # Save API key to .env file ENV_FILE=".env" cat > "$ENV_FILE" << EOF # Porcupine (Picovoice) Configuration # Get your API key from: https://console.picovoice.ai/ PICOVOICE_API_KEY=$api_key EOF echo -e "${GREEN}✓ API key saved to $ENV_FILE${NC}" echo "" echo -e "${BLUE}Step 4: Testing Installation...${NC}" echo "" # Test if Porcupine is available if python3 -c "import pvporcupine; print('Porcupine version:', pvporcupine.__version__)" 2>/dev/null; then echo -e "${GREEN}✓ Porcupine is working!${NC}" else echo -e "${RED}✗ Porcupine test failed${NC}" echo "" echo "Troubleshooting:" echo "1. Make sure you're in the virtual environment" echo "2. Try: source venv/bin/activate" echo "3. Try: pip install pvporcupine" exit 1 fi echo "" echo -e "${GREEN}==========================================" echo " ✅ Setup Complete!" echo "==========================================${NC}" echo "" echo "Porcupine is now installed and configured." echo "" echo "Next steps:" echo "1. Restart your voice assistant:" echo -e " ${BLUE}./start_tui.sh${NC}" echo "" echo "2. Say 'Hey Osiris' to test hotword detection" echo "" echo "3. You should see better hotword detection accuracy" echo "" echo -e "${YELLOW}Note:${NC} Your API key is stored in .env file. Keep it secure!" echo ""