Add interactive Porcupine setup script
This commit is contained in:
parent
2bfc1cd832
commit
3ad34f2259
135
setup_porcupine.sh
Executable file
135
setup_porcupine.sh
Executable file
@ -0,0 +1,135 @@
|
||||
#!/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
|
||||
|
||||
echo -e "${BLUE}"
|
||||
echo "=========================================="
|
||||
echo " 🎤 Porcupine Setup - AI Now Inc"
|
||||
echo "=========================================="
|
||||
echo -e "${NC}"
|
||||
echo ""
|
||||
echo "This script will help you set up Porcupine for accurate hotword detection."
|
||||
echo ""
|
||||
|
||||
# Check if running in virtual environment
|
||||
if [ -z "$VIRTUAL_ENV" ]; then
|
||||
echo -e "${YELLOW}⚠️ Not in a virtual environment.${NC}"
|
||||
echo "Activating virtual environment..."
|
||||
if [ -f "venv/bin/activate" ]; then
|
||||
source venv/bin/activate
|
||||
echo -e "${GREEN}✓ Virtual environment activated${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Virtual environment not found!${NC}"
|
||||
echo "Please run: source venv/bin/activate"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
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 ""
|
||||
|
||||
# Set the API key as environment variable
|
||||
export PICOVOICE_API_KEY="$api_key"
|
||||
|
||||
# Install pvporcupine
|
||||
if 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"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
# Update existing .env file
|
||||
if grep -q "PICOVOICE_API_KEY" "$ENV_FILE"; then
|
||||
sed -i "s/^PICOVOICE_API_KEY=.*/PICOVOICE_API_KEY=$api_key/" "$ENV_FILE"
|
||||
else
|
||||
echo "PICOVOICE_API_KEY=$api_key" >> "$ENV_FILE"
|
||||
fi
|
||||
else
|
||||
# Create new .env file
|
||||
cat > "$ENV_FILE" << EOF
|
||||
# Porcupine (Picovoice) Configuration
|
||||
PICOVOICE_API_KEY=$api_key
|
||||
EOF
|
||||
echo -e "${GREEN}✓ Created .env file with your API key${NC}"
|
||||
fi
|
||||
|
||||
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}"
|
||||
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 '[Porcupine]' instead of '[Simple]' in the logs"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Note:${NC} Your API key is stored in .env file. Keep it secure!"
|
||||
echo ""
|
||||
Loading…
x
Reference in New Issue
Block a user