-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
297 lines (258 loc) · 9.59 KB
/
install.sh
File metadata and controls
297 lines (258 loc) · 9.59 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/bash
# =========================================================================
# SpeakEasy Installer for Linux/macOS
# =========================================================================
# This script:
# - Detects system capabilities (CUDA, GPU)
# - Installs UV package manager (preferred) or falls back to pip
# - Installs Python dependencies with platform-specific optimizations
# - Sets up frontend dependencies
# =========================================================================
set -e
PYTHON_VERSION="3.12"
CUDA_PYTHON_VERSION="12.3"
USE_UV=false
HAS_CUDA=false
echo "=========================================="
echo "SpeakEasy Installer"
echo "=========================================="
echo ""
# -------------------------------------------------------------------------
# 1. Check/Install UV
# -------------------------------------------------------------------------
echo "[STEP 1/3] Checking for 'uv' package manager..."
if command -v uv &> /dev/null; then
echo "[OK] 'uv' found."
USE_UV=true
else
echo "[INFO] 'uv' not found. Attempting to install..."
echo "[INFO] UV is faster than pip and recommended for best experience."
if curl -LsSf https://astral.sh/uv/install.sh | sh; then
echo "[OK] 'uv' installed successfully."
# Source the cargo env to get uv in path immediately
if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
else
export PATH="$HOME/.cargo/bin:$PATH"
fi
USE_UV=true
else
echo "[WARN] Failed to install 'uv'. Will fall back to standard Python/pip."
echo "[INFO] You can install uv manually later from: https://docs.astral.sh/uv/"
fi
fi
# -------------------------------------------------------------------------
# 1.5. Detect System Capabilities
# -------------------------------------------------------------------------
echo ""
echo "[INFO] Detecting system capabilities..."
# Check for NVIDIA GPU and CUDA
if command -v nvidia-smi &> /dev/null; then
echo "[OK] NVIDIA GPU detected."
HAS_CUDA=true
# Try to get GPU info
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null | head -n 1)
if [ -n "$GPU_NAME" ]; then
echo "[INFO] GPU: $GPU_NAME"
fi
# Try to get CUDA version
CUDA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -n 1)
if [ -n "$CUDA_VERSION" ]; then
echo "[INFO] NVIDIA Driver Version: $CUDA_VERSION"
fi
else
echo "[INFO] No NVIDIA GPU detected. Will use CPU-only mode."
HAS_CUDA=false
fi
# Detect OS
OS_TYPE=$(uname -s)
echo "[INFO] Operating System: $OS_TYPE"
# -------------------------------------------------------------------------
# 1.6. Check System Prerequisites
# -------------------------------------------------------------------------
echo ""
echo "[INFO] Checking System Prerequisites..."
if ! command -v ffmpeg &> /dev/null; then
echo "[ERROR] FFmpeg not found in PATH."
echo "[ERROR] SpeakEasy requires FFmpeg for audio processing."
if [ "$OS_TYPE" = "Linux" ]; then
echo "[INFO] Install with: sudo apt install ffmpeg (Debian/Ubuntu) or sudo pacman -S ffmpeg (Arch)"
elif [ "$OS_TYPE" = "Darwin" ]; then
echo "[INFO] Install with: brew install ffmpeg"
fi
exit 1
else
echo "[OK] FFmpeg found."
fi
# -------------------------------------------------------------------------
# 2. Setup Backend (UV or Fallback)
# -------------------------------------------------------------------------
echo ""
echo "[STEP 2/3] Setting up Backend Environment..."
if [ ! -d "backend" ]; then
echo "[ERROR] 'backend' directory not found in: $(pwd)"
exit 1
fi
cd backend
if [ "$USE_UV" = true ]; then
echo "[INFO] Using 'uv' for backend setup..."
# Install Python via uv
echo "[INFO] Ensuring Python $PYTHON_VERSION..."
uv python install $PYTHON_VERSION
# Create venv
echo "[INFO] Creating venv..."
uv venv --python $PYTHON_VERSION --allow-existing
# Install core dependencies
echo "[INFO] Installing core dependencies..."
echo "[INFO] This may take 5-10 minutes on first install..."
uv pip install --python .venv/bin/python -e .
if [ $? -ne 0 ]; then
echo "[ERROR] Core dependency installation failed."
cd ..
exit 1
fi
# Verify installation was successful
echo ""
echo "[INFO] Verifying core installation..."
.venv/bin/python -c "import fastapi; print('FastAPI version:', fastapi.__version__)"
if [ $? -ne 0 ]; then
echo "[ERROR] Core installation failed - FastAPI not found."
cd ..
exit 1
fi
echo "[OK] FastAPI verified successfully."
# Install CUDA-specific optimizations if GPU detected
if [ "$HAS_CUDA" = true ]; then
echo ""
echo "[INFO] Installing CUDA optimizations for faster transcription..."
echo "[INFO] Installing cuda-python>=$CUDA_PYTHON_VERSION..."
uv pip install "cuda-python>=$CUDA_PYTHON_VERSION"
if [ $? -eq 0 ]; then
echo "[OK] CUDA-Python installed successfully."
echo "[INFO] This enables CUDA graph optimizations for 20-30% faster transcription."
else
echo "[WARN] Failed to install cuda-python. Transcription will still work but may be slower."
fi
else
echo "[INFO] Skipping CUDA optimizations (no GPU detected)."
fi
# Install Linux-specific dependencies
if [ "$OS_TYPE" = "Linux" ]; then
echo ""
echo "[INFO] Installing Linux-specific audio dependencies..."
uv pip install "pulsectl>=23.5.0"
if [ $? -eq 0 ]; then
echo "[OK] PulseAudio control installed."
fi
fi
else
echo "[INFO] Using standard Python for backend setup..."
# Check for python3
if ! command -v python3 &> /dev/null; then
echo "[ERROR] 'python3' is required but not found."
exit 1
fi
# Create venv
echo "[INFO] Creating venv with python3..."
python3 -m venv .venv
# Activate and install
echo "[INFO] Activating venv and installing dependencies..."
echo "[INFO] This may take 5-10 minutes on first install..."
# We must activate in the current shell to use pip
. .venv/bin/activate
pip install -e .
if [ $? -ne 0 ]; then
echo "[ERROR] Core dependency installation failed."
cd ..
exit 1
fi
# Explicitly ensure critical backend dependencies are installed
echo ""
echo "[INFO] Ensuring critical backend dependencies are installed..."
pip install "fastapi>=0.109.0" "uvicorn[standard]>=0.27.0" "websockets>=12.0" "slowapi>=0.1.9"
if [ $? -ne 0 ]; then
echo "[ERROR] Failed to install critical backend dependencies."
cd ..
exit 1
fi
# Verify FastAPI installation
echo ""
echo "[INFO] Verifying FastAPI installation..."
.venv/bin/python -c "import fastapi; print('FastAPI version:', fastapi.__version__)"
if [ $? -ne 0 ]; then
echo "[ERROR] FastAPI was not installed correctly."
echo "[ERROR] This is a critical dependency for the web server."
cd ..
exit 1
fi
echo "[OK] FastAPI verified successfully."
# Install CUDA-specific optimizations if GPU detected
if [ "$HAS_CUDA" = true ]; then
echo ""
echo "[INFO] Installing CUDA optimizations for faster transcription..."
echo "[INFO] Installing cuda-python>=$CUDA_PYTHON_VERSION..."
pip install "cuda-python>=$CUDA_PYTHON_VERSION"
if [ $? -eq 0 ]; then
echo "[OK] CUDA-Python installed successfully."
echo "[INFO] This enables CUDA graph optimizations for 20-30% faster transcription."
else
echo "[WARN] Failed to install cuda-python. Transcription will still work but may be slower."
fi
else
echo "[INFO] Skipping CUDA optimizations (no GPU detected)."
fi
# Install Linux-specific dependencies
if [ "$OS_TYPE" = "Linux" ]; then
echo ""
echo "[INFO] Installing Linux-specific audio dependencies..."
pip install "pulsectl>=23.5.0"
if [ $? -eq 0 ]; then
echo "[OK] PulseAudio control installed."
fi
fi
fi
cd ..
# -------------------------------------------------------------------------
# 3. Install Frontend Dependencies
# -------------------------------------------------------------------------
echo ""
echo "[STEP 3/3] Installing Frontend Dependencies (npm)..."
if [ -d "gui" ]; then
cd gui
echo "[INFO] Checking for npm..."
if ! command -v npm &> /dev/null; then
echo "[ERROR] npm is not installed."
echo "[INFO] Please install Node.js (LTS) from https://nodejs.org/"
exit 1
fi
echo "[INFO] Running npm install..."
npm install
cd ..
else
echo "[WARN] 'gui' directory not found. Skipping frontend install."
fi
echo ""
echo "=========================================="
echo "Installation Complete!"
echo "=========================================="
echo ""
echo "System Configuration:"
if [ "$HAS_CUDA" = true ]; then
echo " GPU: NVIDIA GPU with CUDA support"
echo " Optimization: CUDA-Python installed for faster transcription"
else
echo " GPU: None detected (CPU mode)"
echo " Note: GPU recommended for faster transcription"
fi
echo " Package Manager: $([ "$USE_UV" = true ] && echo "uv" || echo "pip")"
echo " Python Version: $PYTHON_VERSION"
echo " OS: $OS_TYPE"
echo ""
echo "To run the application:"
echo " ./start.sh"
echo ""
echo "Next steps:"
echo " 1. Run the application"
echo " 2. First model load will take 30-60 seconds"
echo " 3. Subsequent loads will be faster (~10-15 seconds target)"
echo ""