openclaw-voice-assistant/fix_porcupine.sh
2026-03-01 20:42:13 -08:00

67 lines
1.5 KiB
Bash

#!/bin/bash
#
# Fix Porcupine Installation
# AI Now Inc - Del Mar Demo Unit
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "🔧 Fixing Porcupine Installation..."
echo ""
# Load API key from .env if it exists
if [ -f ".env" ]; then
source .env
if [ -n "$PICOVOICE_API_KEY" ]; then
echo "✓ Found API key in .env"
export PICOVOICE_API_KEY="$PICOVOICE_API_KEY"
else
echo "⚠️ No API key found in .env"
echo "Please run ./setup_porcupine.sh first"
exit 1
fi
else
echo "⚠️ .env file not found"
echo "Please run ./setup_porcupine.sh first"
exit 1
fi
# Check if venv exists and is valid
if [ ! -f "venv/bin/activate" ]; then
echo "📦 Virtual environment not found or broken. Recreating..."
rm -rf venv
python3 -m venv venv
fi
# Activate venv
source venv/bin/activate
# Upgrade pip
echo "📦 Upgrading pip..."
pip install --upgrade pip
# Install Porcupine
echo "🎤 Installing Porcupine..."
pip install pvporcupine
# Test installation
echo ""
echo "🧪 Testing Porcupine installation..."
if python3 -c "import pvporcupine; print('✓ Porcupine version:', pvporcupine.__version__)"; then
echo ""
echo "✅ Porcupine installed successfully!"
echo ""
echo "Now you can run:"
echo " ./start_tui.sh"
echo ""
echo "Say 'Hey Osiris' to test hotword detection."
else
echo ""
echo "❌ Porcupine installation failed!"
echo "Please check your API key and internet connection."
exit 1
fi