Fix setup script to check for venv and provide better instructions

This commit is contained in:
Claw - AI Now Inc 2026-03-01 13:05:43 -08:00
parent 3ad34f2259
commit 7e1c98a1aa

View File

@ -15,30 +15,36 @@ YELLOW='\033[1;33m'
RED='\033[0;31m' RED='\033[0;31m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo -e "${BLUE}" echo -e "${BLUE}"
echo "==========================================" echo "=========================================="
echo " 🎤 Porcupine Setup - AI Now Inc" echo " 🎤 Porcupine Setup - AI Now Inc"
echo "==========================================" echo "=========================================="
echo -e "${NC}" echo -e "${NC}"
echo "" echo ""
echo "This script will help you set up Porcupine for accurate hotword detection."
echo ""
# Check if running in virtual environment # Check if virtual environment exists
if [ -z "$VIRTUAL_ENV" ]; then if [ ! -d "venv" ]; then
echo -e "${YELLOW}⚠️ Not in a virtual environment.${NC}" echo -e "${RED}✗ Virtual environment not found!${NC}"
echo "Activating virtual environment..." echo ""
if [ -f "venv/bin/activate" ]; then echo "Please run the installer first:"
source venv/bin/activate echo " sudo ./install.sh"
echo -e "${GREEN}✓ Virtual environment activated${NC}" echo ""
else echo "Or create the virtual environment manually:"
echo -e "${RED}✗ Virtual environment not found!${NC}" echo " python3 -m venv venv"
echo "Please run: source venv/bin/activate" echo " source venv/bin/activate"
exit 1 echo " pip install -r requirements.txt"
fi exit 1
fi fi
# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate
echo -e "${GREEN}✓ Virtual environment activated${NC}"
echo "" echo ""
echo "Step 1: Get Your API Key" echo "Step 1: Get Your API Key"
echo "━━━━━━━━━━━━━━━━━━━━━━━━" echo "━━━━━━━━━━━━━━━━━━━━━━━━"
echo "" echo ""
@ -68,11 +74,8 @@ echo ""
echo -e "${BLUE}Step 2: Installing Porcupine...${NC}" echo -e "${BLUE}Step 2: Installing Porcupine...${NC}"
echo "" echo ""
# Set the API key as environment variable # Install pvporcupine with the API key
export PICOVOICE_API_KEY="$api_key" if PICOVOICE_API_KEY="$api_key" pip install pvporcupine; then
# Install pvporcupine
if pip install pvporcupine; then
echo -e "${GREEN}✓ Porcupine installed successfully!${NC}" echo -e "${GREEN}✓ Porcupine installed successfully!${NC}"
else else
echo -e "${RED}✗ Failed to install Porcupine${NC}" echo -e "${RED}✗ Failed to install Porcupine${NC}"
@ -86,21 +89,11 @@ echo ""
# Save API key to .env file # Save API key to .env file
ENV_FILE=".env" ENV_FILE=".env"
if [ -f "$ENV_FILE" ]; then cat > "$ENV_FILE" << EOF
# 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 # Porcupine (Picovoice) Configuration
# Get your API key from: https://console.picovoice.ai/
PICOVOICE_API_KEY=$api_key PICOVOICE_API_KEY=$api_key
EOF EOF
echo -e "${GREEN}✓ Created .env file with your API key${NC}"
fi
echo -e "${GREEN}✓ API key saved to $ENV_FILE${NC}" echo -e "${GREEN}✓ API key saved to $ENV_FILE${NC}"
@ -113,6 +106,11 @@ if python3 -c "import pvporcupine; print('Porcupine version:', pvporcupine.__ver
echo -e "${GREEN}✓ Porcupine is working!${NC}" echo -e "${GREEN}✓ Porcupine is working!${NC}"
else else
echo -e "${RED}✗ Porcupine test failed${NC}" 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 exit 1
fi fi
@ -129,7 +127,7 @@ echo -e " ${BLUE}./start_tui.sh${NC}"
echo "" echo ""
echo "2. Say 'Hey Osiris' to test hotword detection" echo "2. Say 'Hey Osiris' to test hotword detection"
echo "" echo ""
echo "3. You should see '[Porcupine]' instead of '[Simple]' in the logs" echo "3. You should see better hotword detection accuracy"
echo "" echo ""
echo -e "${YELLOW}Note:${NC} Your API key is stored in .env file. Keep it secure!" echo -e "${YELLOW}Note:${NC} Your API key is stored in .env file. Keep it secure!"
echo "" echo ""