-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bat
More file actions
476 lines (414 loc) · 17 KB
/
install.bat
File metadata and controls
476 lines (414 loc) · 17 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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
@echo off
setlocal EnableDelayedExpansion
REM =========================================================================
REM SpeakEasy Installer for Windows
REM =========================================================================
REM This script:
REM - Detects system capabilities (CUDA, GPU)
REM - Installs UV package manager (preferred) or falls back to pip
REM - Installs Python dependencies with platform-specific optimizations
REM - Sets up frontend dependencies
REM =========================================================================
REM -------------------------------------------------------------------------
REM Configuration
REM -------------------------------------------------------------------------
set "PYTHON_TARGET_VERSION=3.12"
set "CUDA_PYTHON_VERSION=12.3"
set "USE_UV=false"
set "HAS_CUDA=false"
set "INSTALL_LOG=%~dp0install.log"
REM -------------------------------------------------------------------------
REM Set Working Directory
REM -------------------------------------------------------------------------
cd /d "%~dp0"
echo ========================================== > "%INSTALL_LOG%"
echo SpeakEasy Installation Log >> "%INSTALL_LOG%"
echo Started: %DATE% %TIME% >> "%INSTALL_LOG%"
echo ========================================== >> "%INSTALL_LOG%"
echo. >> "%INSTALL_LOG%"
echo ==========================================
echo SpeakEasy Installer
echo ==========================================
echo.
echo Installation log: %INSTALL_LOG%
echo.
REM -------------------------------------------------------------------------
REM 1. Check/Install UV
REM -------------------------------------------------------------------------
echo [STEP 1/4] Checking for 'uv' package manager...
echo [STEP 1/4] Checking for 'uv' package manager... >> "%INSTALL_LOG%"
set "USE_UV=false"
where uv >nul 2>nul
if %errorlevel% equ 0 (
echo [OK] 'uv' found.
echo [OK] 'uv' found. >> "%INSTALL_LOG%"
set "USE_UV=true"
) else (
echo [INFO] 'uv' not found. Attempting to install...
echo [INFO] 'uv' not found. Attempting to install... >> "%INSTALL_LOG%"
echo [INFO] UV is faster than pip and recommended for best experience.
echo [INFO] This will take 10-30 seconds...
powershell -NoProfile -ExecutionPolicy ByPass -Command "& {irm https://astral.sh/uv/install.ps1 | iex}" >> "%INSTALL_LOG%" 2>&1
if !errorlevel! equ 0 (
echo [OK] 'uv' installed successfully.
echo [OK] 'uv' installed successfully. >> "%INSTALL_LOG%"
REM Update PATH for this session - check multiple possible locations
if exist "%LOCALAPPDATA%\bin\uv.exe" (
set "PATH=%LOCALAPPDATA%\bin;%PATH%"
echo [INFO] Added %LOCALAPPDATA%\bin to PATH >> "%INSTALL_LOG%"
)
if exist "%USERPROFILE%\.cargo\bin\uv.exe" (
set "PATH=%USERPROFILE%\.cargo\bin;%PATH%"
echo [INFO] Added %USERPROFILE%\.cargo\bin to PATH >> "%INSTALL_LOG%"
)
REM Verify UV is now available
where uv >nul 2>nul
if !errorlevel! equ 0 (
set "USE_UV=true"
echo [OK] UV is now available in PATH.
echo [OK] UV is now available in PATH. >> "%INSTALL_LOG%"
) else (
echo [WARN] UV installed but not found in PATH. Will use pip instead.
echo [WARN] UV installed but not found in PATH. Will use pip instead. >> "%INSTALL_LOG%"
)
) else (
echo [WARN] Failed to install uv. Will fall back to standard Python/pip.
echo [WARN] Failed to install uv. Will fall back to standard Python/pip. >> "%INSTALL_LOG%"
echo [INFO] You can install uv manually later from: https://docs.astral.sh/uv/
)
)
REM -------------------------------------------------------------------------
REM 2. Detect System Capabilities
REM -------------------------------------------------------------------------
echo.
echo [STEP 2/4] Detecting system capabilities...
echo [STEP 2/4] Detecting system capabilities... >> "%INSTALL_LOG%"
REM Check for NVIDIA GPU and CUDA
nvidia-smi >nul 2>nul
if %errorlevel% equ 0 (
echo [OK] NVIDIA GPU detected.
echo [OK] NVIDIA GPU detected. >> "%INSTALL_LOG%"
set "HAS_CUDA=true"
REM Try to get CUDA version - simpler approach
echo [INFO] Querying GPU information...
nvidia-smi --query-gpu=driver_version --format=csv,noheader > "%TEMP%\nvsmi_version.txt" 2>nul
if exist "%TEMP%\nvsmi_version.txt" (
set /p DRIVER_VERSION=<"%TEMP%\nvsmi_version.txt"
del "%TEMP%\nvsmi_version.txt"
if defined DRIVER_VERSION (
echo [INFO] NVIDIA Driver Version: !DRIVER_VERSION!
echo [INFO] NVIDIA Driver Version: !DRIVER_VERSION! >> "%INSTALL_LOG%"
)
)
) else (
echo [INFO] No NVIDIA GPU detected. Will use CPU-only mode.
echo [INFO] No NVIDIA GPU detected. Will use CPU-only mode. >> "%INSTALL_LOG%"
set "HAS_CUDA=false"
)
REM -------------------------------------------------------------------------
REM 2b. Check System Prerequisites (FFmpeg, C++ Tools)
REM -------------------------------------------------------------------------
echo.
echo [INFO] Checking for FFmpeg...
where ffmpeg >nul 2>nul
if %errorlevel% neq 0 (
echo [ERROR] FFmpeg not found in PATH.
echo [ERROR] FFmpeg not found in PATH. >> "%INSTALL_LOG%"
echo [ERROR] SpeakEasy requires FFmpeg for audio processing.
echo [ERROR] Please download from: https://ffmpeg.org/download.html
echo [ERROR] Or use winget: winget install Gyan.FFmpeg
echo [ERROR] Then add it to your PATH and restart this installer.
pause
exit /b 1
) else (
echo [OK] FFmpeg found.
echo [OK] FFmpeg found. >> "%INSTALL_LOG%"
)
echo [INFO] Checking for Visual C++ Build Tools...
echo [INFO] Note: Some dependencies (like texterrors) require C++ compilation.
echo [INFO] If installation fails with "Microsoft Visual C++ 14.0 or greater is required",
echo [INFO] please install "Desktop development with C++" workload from Visual Studio Build Tools.
echo [INFO] Download: https://visualstudio.microsoft.com/visual-cpp-build-tools/
echo [INFO] Checked C++ Tools warning. >> "%INSTALL_LOG%"
REM -------------------------------------------------------------------------
REM 3. Setup Backend Environment
REM -------------------------------------------------------------------------
echo.
echo [STEP 3/4] Setting up Backend Environment...
echo [STEP 3/4] Setting up Backend Environment... >> "%INSTALL_LOG%"
echo [INFO] This may take 5-10 minutes on first install (downloading models)...
if not exist "backend" (
echo [ERROR] 'backend' directory not found in: %CD%
echo [ERROR] 'backend' directory not found in: %CD% >> "%INSTALL_LOG%"
echo [ERROR] Please run this script from the SpeakEasy root directory.
echo.
pause
exit /b 1
)
echo [INFO] Changed to backend directory: %CD%
echo [INFO] Changed to backend directory: %CD% >> "%INSTALL_LOG%"
cd backend
echo [INFO] Now in: %CD%
echo [INFO] Now in: %CD% >> "%INSTALL_LOG%"
echo [CHECKPOINT] About to check USE_UV flag >> "%INSTALL_LOG%"
if "!USE_UV!"=="true" goto :SetupUV
goto :SetupPython
:SetupUV
echo [INFO] Using 'uv' for backend setup...
echo [INFO] Using 'uv' for backend setup... >> "%INSTALL_LOG%"
echo [INFO] Removing old environment if it exists...
if exist ".venv" (
echo [INFO] Old .venv directory found. Removing...
rmdir /s /q .venv
if exist ".venv" (
echo [ERROR] Failed to delete '.venv' directory.
echo [ERROR] Access is denied. A process may be locking the files.
echo [ERROR] Please close all terminals and try again.
cd ..
pause
exit /b 1
)
)
echo [INFO] Creating virtual environment with UV...
call uv venv
if !errorlevel! neq 0 (
echo [ERROR] Failed to create virtual environment.
echo [ERROR] Failed to create virtual environment. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
if not exist ".venv\Scripts\python.exe" (
echo [ERROR] Virtual environment was not created properly.
echo [ERROR] Virtual environment was not created properly. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo [OK] Virtual environment created successfully.
echo [OK] Virtual environment created successfully. >> "%INSTALL_LOG%"
echo.
echo [INFO] Installing core dependencies (downloading PyTorch, NeMo, etc.)...
echo [INFO] This is the longest step - please be patient (5-10 minutes)...
echo [INFO] You will see progress output below...
echo.
if "!HAS_CUDA!"=="true" goto :InstallCudaUV
goto :InstallCpuUV
:InstallCudaUV
echo [INFO] Installing with CUDA optimization for faster transcription...
echo [INFO] GPU detected - enabling CUDA support...
call uv pip install --python ".venv\Scripts\python.exe" -e ".[cuda]"
echo [INFO] Ensuring cuda-python is installed...
call uv pip install --python ".venv\Scripts\python.exe" "dill"
call uv pip install --python ".venv\Scripts\python.exe" "cuda-python>=12.3"
goto :InstallDoneUV
:InstallCpuUV
echo [INFO] Installing in CPU mode (no GPU detected)...
call uv pip install --python ".venv\Scripts\python.exe" -e .
goto :InstallDoneUV
:InstallDoneUV
if !errorlevel! neq 0 (
echo [ERROR] Core dependency installation failed.
echo [ERROR] Core dependency installation failed. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo.
echo [OK] Dependencies installed successfully.
echo [OK] Dependencies installed successfully. >> "%INSTALL_LOG%"
if "!HAS_CUDA!"=="true" (
echo [INFO] CUDA optimizations enabled for 20-30%% faster transcription.
echo [INFO] CUDA optimizations enabled. >> "%INSTALL_LOG%"
)
goto :BackendSetupDone
:SetupPython
echo [CHECKPOINT] UV not enabled, using standard Python >> "%INSTALL_LOG%"
echo [INFO] Using standard Python for backend setup...
echo [INFO] Using standard Python for backend setup... >> "%INSTALL_LOG%"
where python >nul 2>nul
if !errorlevel! neq 0 (
echo [ERROR] 'python' not found. Please install Python 3.12 or newer.
echo [ERROR] 'python' not found. >> "%INSTALL_LOG%"
echo [ERROR] Download from: https://www.python.org/downloads/
cd ..
pause
exit /b 1
)
REM Check Python version
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set "PYTHON_VERSION=%%i"
echo [INFO] Found Python !PYTHON_VERSION!
echo [INFO] Found Python !PYTHON_VERSION! >> "%INSTALL_LOG%"
echo [INFO] Removing old environment if it exists...
if exist ".venv" (
echo [INFO] Old .venv directory found. Removing...
rmdir /s /q .venv
if exist ".venv" (
echo [ERROR] Failed to delete '.venv' directory.
echo [ERROR] Access is denied. A process may be locking the files.
echo [ERROR] Please close all terminals and try again.
cd ..
pause
exit /b 1
)
)
echo [INFO] Creating virtual environment with Python...
python -m venv .venv
if !errorlevel! neq 0 (
echo [ERROR] Failed to create virtual environment.
echo [ERROR] Failed to create virtual environment. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo [OK] Virtual environment created.
echo [OK] Virtual environment created. >> "%INSTALL_LOG%"
echo [INFO] Activating virtual environment...
call .venv\Scripts\activate.bat
if !errorlevel! neq 0 (
echo [ERROR] Failed to activate virtual environment.
echo [ERROR] Failed to activate virtual environment. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo [INFO] Upgrading pip...
python -m pip install --upgrade pip >nul 2>&1
echo.
echo [INFO] Installing core dependencies (downloading PyTorch, NeMo, etc.)...
echo [INFO] This is the longest step - please be patient (5-10 minutes)...
echo [INFO] You will see progress output below...
echo.
if "!HAS_CUDA!"=="true" goto :InstallCudaPip
goto :InstallCpuPip
:InstallCudaPip
echo [INFO] Installing with CUDA optimization for faster transcription...
echo [INFO] GPU detected - enabling CUDA support...
pip install -e ".[cuda]"
echo [INFO] Ensuring cuda-python is installed...
pip install "cuda-python>=12.3"
goto :InstallDonePip
:InstallCpuPip
echo [INFO] Installing in CPU mode (no GPU detected)...
pip install -e .
goto :InstallDonePip
:InstallDonePip
if !errorlevel! neq 0 (
echo [ERROR] Core dependency installation failed.
echo [ERROR] Core dependency installation failed. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo.
echo [OK] Dependencies installed successfully.
echo [OK] Dependencies installed successfully. >> "%INSTALL_LOG%"
REM Explicitly ensure critical backend dependencies are installed
echo [INFO] Ensuring critical backend dependencies are installed...
echo [INFO] Ensuring critical backend dependencies are installed... >> "%INSTALL_LOG%"
pip install "fastapi>=0.109.0" "uvicorn[standard]>=0.27.0" "websockets>=12.0" "slowapi>=0.1.9"
if !errorlevel! neq 0 (
echo [ERROR] Failed to install critical backend dependencies.
echo [ERROR] Failed to install critical backend dependencies. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo [INFO] Verifying FastAPI installation...
echo [INFO] Verifying FastAPI installation... >> "%INSTALL_LOG%"
.venv\Scripts\python.exe -c "import fastapi; print('FastAPI version:', fastapi.__version__)"
if !errorlevel! neq 0 (
echo [ERROR] FastAPI was not installed correctly.
echo [ERROR] FastAPI was not installed correctly. >> "%INSTALL_LOG%"
echo [ERROR] This is a critical dependency for the web server.
cd ..
pause
exit /b 1
)
echo [OK] FastAPI verified successfully.
echo [OK] FastAPI verified successfully. >> "%INSTALL_LOG%"
if "!HAS_CUDA!"=="true" (
echo [INFO] CUDA optimizations enabled for 20-30%% faster transcription.
echo [INFO] CUDA optimizations enabled. >> "%INSTALL_LOG%"
)
goto :BackendSetupDone
:BackendSetupDone
cd ..
REM -------------------------------------------------------------------------
REM 4. Install Frontend Dependencies
REM -------------------------------------------------------------------------
echo.
echo [STEP 4/4] Installing Frontend Dependencies (npm)...
echo [STEP 4/4] Installing Frontend Dependencies (npm)... >> "%INSTALL_LOG%"
if exist "gui" (
cd gui
echo [INFO] Checking for npm...
where npm >nul 2>nul
if !errorlevel! neq 0 (
echo [ERROR] npm is not installed or not in PATH.
echo [ERROR] npm is not installed or not in PATH. >> "%INSTALL_LOG%"
echo [ERROR] Please install Node.js ^(LTS^) from https://nodejs.org/
cd ..
pause
exit /b 1
)
REM Check npm version
for /f "tokens=*" %%i in ('npm --version 2^>^&1') do set "NPM_VERSION=%%i"
echo [INFO] Found npm !NPM_VERSION!
echo [INFO] Found npm !NPM_VERSION! >> "%INSTALL_LOG%"
echo [INFO] Running npm install ^(this may take 2-3 minutes^)...
call npm install
if !errorlevel! neq 0 (
echo [ERROR] Frontend installation failed.
echo [ERROR] Frontend installation failed. >> "%INSTALL_LOG%"
cd ..
pause
exit /b 1
)
echo [OK] Frontend dependencies installed.
echo [OK] Frontend dependencies installed. >> "%INSTALL_LOG%"
cd ..
) else (
echo [WARN] 'gui' directory not found. Skipping frontend install.
echo [WARN] 'gui' directory not found. >> "%INSTALL_LOG%"
)
REM -------------------------------------------------------------------------
REM Installation Complete
REM -------------------------------------------------------------------------
echo.
echo ========================================== >> "%INSTALL_LOG%"
echo Installation Complete: %DATE% %TIME% >> "%INSTALL_LOG%"
echo ========================================== >> "%INSTALL_LOG%"
echo.
echo ==========================================
echo Installation Complete!
echo ==========================================
echo.
echo System Configuration:
if "!HAS_CUDA!"=="true" (
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
)
if "!USE_UV!"=="true" (
echo Package Manager: UV ^(fast^)
) else (
echo Package Manager: pip ^(standard^)
)
echo Python Version: %PYTHON_TARGET_VERSION%
echo.
echo To run the application:
echo Double-click start.bat
echo.
echo Next steps:
echo 1. Run the application with start.bat
echo 2. First model load will take 30-60 seconds
echo 3. Subsequent loads will be faster ^(~10-15 seconds target^)
echo.
echo If you encounter any issues:
echo - Check the installation log: %INSTALL_LOG%
echo - Report issues at: https://github.com/yourusername/SpeakEasy/issues
echo.
pause