Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,63 @@ https://github.com/user-attachments/assets/6b8c08a8-c84f-4fc3-83ad-5703f474fc1b

## Requirements

### Windows
- **Python 3.11+**
- **CUDA-compatible GPU** (4GB+ VRAM for lite mode, 12GB+ for full mode)
- **CUDA 12.6** (recommended)
- **Node.js 18+** (for frontend)

> 💡 FFmpeg and Redis are automatically installed by the installer.
### macOS
- **Python 3.11+**
- **Apple Silicon (M1/M2/M3/M4)** or Intel Mac
- **Node.js 18+** (for frontend)
- **Homebrew** (for Redis installation)

> 💡 **Note for Mac users**: The application uses CPU processing to avoid MPS (Metal Performance Shaders) compatibility issues. This is slower but more stable.

### Linux
- **Python 3.11+**
- **CUDA-compatible GPU** (4GB+ VRAM for lite mode, 12GB+ for full mode) or CPU
- **CUDA 12.6** (recommended for GPU)
- **Node.js 18+** (for frontend)

> 💡 FFmpeg and Redis are automatically installed by the installer on all platforms.

## 🚀 One-Click Installation (Recommended)

### First Time Setup
### Windows

**First Time Setup:**
```bash
# Run installer (creates Conda env, downloads Redis, installs all dependencies)
install.bat
windows\install.bat
```

**Daily Usage:**
```bash
# Start all services with one click
windows\start.bat

# Stop all services
windows\stop.bat
```

### macOS / Linux

**First Time Setup:**
```bash
# Run installer (creates Conda env, installs Redis, installs all dependencies)
chmod +x unix/*.sh
./unix/install.sh
```

### Daily Usage
**Daily Usage:**
```bash
# Start all services with one click
start.bat
./unix/start.sh

# Stop all services
stop.bat
./unix/stop.sh
```

---
Expand Down Expand Up @@ -233,12 +268,20 @@ audioghost-ai/
│ │ └── separate.py # Separation endpoints
│ └── workers/
│ ├── celery_app.py # Celery config
│ └── tasks.py # SAM Audio Lite worker
│ └── tasks.py # SAM Audio Lite worker (with Mac CPU fix)
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js app
│ │ └── components/ # React components
│ └── package.json
├── windows/ # Windows-specific scripts
│ ├── install.bat # One-click installer for Windows
│ ├── start.bat # Start all services (Windows)
│ └── stop.bat # Stop all services (Windows)
├── unix/ # macOS/Linux scripts
│ ├── install.sh # One-click installer for Unix
│ ├── start.sh # Start all services (Unix)
│ └── stop.sh # Stop all services (Unix)
├── sam_audio_lite.py # Standalone lite version
├── QUICKSTART.md # Quick setup guide
└── README.md
Expand Down
12 changes: 11 additions & 1 deletion backend/workers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,17 @@ def separate_audio_task(
from huggingface_hub import login

task_id = self.request.id
device = "cuda" if torch.cuda.is_available() else "cpu"

# Force CPU on Mac to avoid MPS memory issues
# MPS (Metal Performance Shaders) can cause SIGABRT crashes with large models
# Windows/Linux: Use CUDA if available, otherwise CPU
if sys.platform == "darwin": # macOS
device = "cpu"
print(f"[DEBUG] Detected macOS - forcing CPU to avoid MPS issues")
else:
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"[DEBUG] Using device: {device}")

video_path = None # Will be set if input is video

# Debug: Show received parameter
Expand Down
112 changes: 112 additions & 0 deletions unix/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash
set -e

echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ AudioGhost AI - One-Click Installer ║"
echo "║ v1.0 MVP ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""

# Get the project root directory (parent of the script directory)
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
cd "$PROJECT_ROOT"

# Check if Conda is installed
if ! command -v conda &> /dev/null; then
echo "[ERROR] Conda not found. Please install Anaconda or Miniconda first."
echo "Download from: https://www.anaconda.com/download"
exit 1
fi

# Detect OS and install Redis if needed
echo "[1/8] Checking Redis..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS - use Homebrew
if ! command -v redis-server &> /dev/null; then
echo "Installing Redis via Homebrew..."
if ! command -v brew &> /dev/null; then
echo "[ERROR] Homebrew not found. Install from: https://brew.sh"
exit 1
fi
brew install redis
else
echo "Redis already installed, skipping..."
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux - use package manager
if ! command -v redis-server &> /dev/null; then
echo "Installing Redis..."
if command -v apt-get &> /dev/null; then
sudo apt-get update && sudo apt-get install -y redis-server
elif command -v yum &> /dev/null; then
sudo yum install -y redis
else
echo "[WARN] Could not install Redis automatically. Please install manually."
fi
else
echo "Redis already installed, skipping..."
fi
fi

echo ""
echo "[2/8] Creating Conda environment 'audioghost' (Python 3.11)..."
conda create -n audioghost python=3.11 -y || echo "[WARN] Environment may already exist, continuing..."

echo ""
echo "[3/8] Activating environment..."
eval "$(conda shell.bash hook)"
conda activate audioghost

echo ""
echo "[4/8] Installing PyTorch..."
echo "This may take several minutes..."

# Detect platform and install appropriate PyTorch
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS - use CPU/MPS build
echo "Detected macOS - installing PyTorch with MPS support..."
pip install torch torchvision torchaudio
else
# Linux - install CUDA build
echo "Detected Linux - installing PyTorch with CUDA 12.6..."
pip install torch==2.9.0+cu126 torchvision==0.24.0+cu126 torchaudio==2.9.0+cu126 \
--index-url https://download.pytorch.org/whl/cu126 \
--extra-index-url https://pypi.org/simple
fi

echo ""
echo "[5/8] Installing FFmpeg..."
conda install -c conda-forge ffmpeg -y

echo ""
echo "[6/8] Installing SAM Audio..."
pip install git+https://github.com/facebookresearch/sam-audio.git

echo ""
echo "[7/8] Installing Backend dependencies..."
cd backend
pip install -r requirements.txt
cd ..

echo ""
echo "[8/8] Installing Frontend dependencies..."
cd frontend
npm install
cd ..

echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Installation Complete! ✓ ║"
echo "╠══════════════════════════════════════════════════════════════╣"
echo "║ ║"
echo "║ To start AudioGhost, run: ./start.sh ║"
echo "║ ║"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "║ On macOS, Redis is managed by Homebrew. ║"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "║ On Linux, Redis is installed as a system service. ║"
fi
echo "║ ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
110 changes: 110 additions & 0 deletions unix/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash
set -e

echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ AudioGhost AI - Launcher ║"
echo "║ v1.0 MVP ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""

# Get the project root directory (parent of the script directory)
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
cd "$PROJECT_ROOT"

# Function to wait for a service to be ready
wait_for_service() {
local port=$1
local service_name=$2
local max_attempts=30
local attempt=0

echo " Waiting for $service_name to be ready..."
while ! nc -z localhost $port 2>/dev/null; do
attempt=$((attempt + 1))
if [ $attempt -ge $max_attempts ]; then
echo " [WARN] $service_name didn't start in time, continuing anyway..."
return 1
fi
sleep 1
done
echo " $service_name is ready! ✓"
}

# Check if Redis is running
echo "[1/4] Checking Redis..."
if nc -z localhost 6379 2>/dev/null; then
echo " Redis detected - using existing instance"
else
echo " Starting Redis..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS - use Homebrew
brew services start redis 2>/dev/null || redis-server --daemonize yes
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux - try systemd or docker
if command -v systemctl &> /dev/null; then
sudo systemctl start redis-server 2>/dev/null || sudo systemctl start redis 2>/dev/null || docker-compose up -d
else
docker-compose up -d
fi
fi
sleep 2
fi

echo "[2/4] Starting Backend API..."
# Start backend in background with proper conda activation
(cd "$PROJECT_ROOT/backend" && eval "$(conda shell.bash hook)" && conda activate audioghost && uvicorn main:app --reload --port 8000 > /tmp/audioghost-backend.log 2>&1) &
BACKEND_PID=$!
echo " Backend starting (PID: $BACKEND_PID, logs: /tmp/audioghost-backend.log)"
wait_for_service 8000 "Backend API"

echo "[3/4] Starting Celery Worker..."
# Start celery in background with proper conda activation
(cd "$PROJECT_ROOT/backend" && eval "$(conda shell.bash hook)" && conda activate audioghost && celery -A workers.celery_app worker --loglevel=info > /tmp/audioghost-celery.log 2>&1) &
CELERY_PID=$!
echo " Celery starting (PID: $CELERY_PID, logs: /tmp/audioghost-celery.log)"
sleep 3 # Give Celery time to connect to Redis

echo "[4/4] Starting Frontend..."
# Start frontend in background
(cd "$PROJECT_ROOT/frontend" && npm run dev > /tmp/audioghost-frontend.log 2>&1) &
FRONTEND_PID=$!
echo " Frontend starting (PID: $FRONTEND_PID, logs: /tmp/audioghost-frontend.log)"
wait_for_service 3000 "Frontend"

echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ All Services Started! ✓ ║"
echo "╠══════════════════════════════════════════════════════════════╣"
echo "║ ║"
echo "║ Frontend: http://localhost:3000 ║"
echo "║ Backend: http://localhost:8000 ║"
echo "║ API Docs: http://localhost:8000/docs ║"
echo "║ ║"
echo "║ Services running in background: ║"
echo "║ - Redis: PID $(lsof -ti :6379 2>/dev/null | head -1 || echo 'N/A') ║"
echo "║ - Backend: PID $BACKEND_PID ║"
echo "║ - Celery: PID $CELERY_PID ║"
echo "║ - Frontend: PID $FRONTEND_PID ║"
echo "║ ║"
echo "║ View logs: ║"
echo "║ - Backend: tail -f /tmp/audioghost-backend.log ║"
echo "║ - Celery: tail -f /tmp/audioghost-celery.log ║"
echo "║ - Frontend: tail -f /tmp/audioghost-frontend.log ║"
echo "║ ║"
echo "║ Run ./stop.sh to stop all services. ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo "Opening browser in 3 seconds..."
sleep 3

# Open browser automatically
if [[ "$OSTYPE" == "darwin"* ]]; then
open http://localhost:3000
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
xdg-open http://localhost:3000 2>/dev/null || echo "Please open http://localhost:3000 in your browser"
fi

echo ""
echo "All services are running! Press Ctrl+C to return to shell."
echo "(Services will continue running in background)"
41 changes: 41 additions & 0 deletions unix/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ AudioGhost AI - Shutdown ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""

echo "Stopping all AudioGhost services..."
echo ""

# Kill Frontend (Node.js/npm)
echo "[1/4] Stopping Frontend..."
pkill -f "npm run dev" 2>/dev/null || true
pkill -f "next-router-worker" 2>/dev/null || true

# Kill Celery Worker
echo "[2/4] Stopping Celery Worker..."
pkill -f "celery.*audioghost" 2>/dev/null || true

# Kill Backend (Uvicorn)
echo "[3/4] Stopping Backend API..."
pkill -f "uvicorn main:app" 2>/dev/null || true

# Stop Redis (Docker)
echo "[4/4] Stopping Redis..."
if command -v docker-compose &> /dev/null; then
docker-compose down 2>/dev/null || true
fi

# Stop Redis (Homebrew on Mac)
if [[ "$OSTYPE" == "darwin"* ]]; then
brew services stop redis 2>/dev/null || true
fi

echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ All Services Stopped! ✓ ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""

Loading