diff --git a/setup_porcupine.sh b/setup_porcupine.sh index e81c7ba..e43da32 100755 --- a/setup_porcupine.sh +++ b/setup_porcupine.sh @@ -15,30 +15,36 @@ 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 "" -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 +# 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 "" @@ -68,11 +74,8 @@ 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 +# 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}" @@ -86,21 +89,11 @@ 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 +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}✓ Created .env file with your API key${NC}" -fi 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}" 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 @@ -129,7 +127,7 @@ 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 "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 ""