File size: 3,896 Bytes
21328a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4062620
 
 
21328a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9fe2444
 
 
21328a8
9fe2444
21328a8
 
 
 
 
9fe2444
 
 
 
 
 
 
21328a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Speech-X β€” First-time environment setup
# Creates the conda 'avatar' environment and installs all dependencies in stages.
# Run from the repo root: bash setup/setup.sh

set -e

CONDA_ENV="avatar"

echo "=== Speech-X Setup (conda env: $CONDA_ENV) ==="

# ── Stage 0: sanity checks ───────────────────────────────────────────────────
if ! command -v conda &>/dev/null; then
    echo "ERROR: conda not found."
    echo "Install Miniconda: https://docs.conda.io/en/latest/miniconda.html"
    exit 1
fi

# Ensure conda is initialized for zsh/bash in this container
conda init bash zsh &>/dev/null

if command -v nvidia-smi &>/dev/null; then
    echo "GPU detected:"
    nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
else
    echo "WARNING: nvidia-smi not found β€” CPU-only mode."
fi

# ── Stage 1: Create conda environment ────────────────────────────────────────
if conda env list | grep -q "^$CONDA_ENV "; then
    echo "Conda env '$CONDA_ENV' already exists β€” skipping creation."
else
    echo "Creating conda env '$CONDA_ENV' (Python 3.12)..."
    conda create -y -n "$CONDA_ENV" python=3.12
fi

RUN="conda run -n $CONDA_ENV"

# ── Stage 2: PyTorch ─────────────────────────────────────────────────────────
echo "Installing PyTorch 2.5.1 + CUDA 12.4..."
$RUN pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
    --index-url https://download.pytorch.org/whl/cu124

# ── Stage 3: MMLab packages ──────────────────────────────────────────────────
echo "Installing MMLab packages..."
$RUN pip install --no-cache-dir -U openmim
# Force setuptools to a version compatible with Python 3.12 (>=63.2) but older than 70
# to preserve pkg_resources behavior expected by openmim/openxlab.
$RUN pip install "setuptools==69.5.1"
$RUN mim install mmengine
$RUN pip install "mmcv-lite==2.2.0"
$RUN mim install "mmdet==3.3.0"
# Note: mmpose not required β€” not present in the reference env

# ── Stage 4: MuseTalk core deps ──────────────────────────────────────────────
echo "Installing MuseTalk dependencies..."
# broken into chunks to show progress and avoid seeming "frozen"
$RUN pip install "numpy==2.4.2" "opencv-python==4.13.0.92"
$RUN pip install diffusers==0.30.2 accelerate==0.28.0
# tokenizers is automatically handled by transformers
$RUN pip install "transformers==4.39.2" "huggingface-hub==0.36.2"
$RUN pip install "soundfile==0.12.1" "librosa==0.10.2" "einops==0.8.1"
$RUN pip install gdown requests "imageio==2.34.0" imageio-ffmpeg "omegaconf==2.3.0" ffmpeg-python moviepy

# ── Stage 5: Project-specific deps ───────────────────────────────────────────
echo "Installing project dependencies..."
$RUN pip install -r backend/requirements.txt

# ── Frontend ─────────────────────────────────────────────────────────────────
echo "Installing frontend dependencies..."
(cd frontend && npm install)

echo ""
echo "=== Setup complete ==="
echo ""
echo "Activate:       conda activate $CONDA_ENV"
echo "Avatar page:    conda activate $CONDA_ENV && cd backend && python api/server.py"
echo "Voice agent:    conda activate $CONDA_ENV && cd backend && python agent.py dev"
echo "Frontend:       cd frontend && npm run dev"