-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathrun.bat
More file actions
113 lines (103 loc) · 4.34 KB
/
Copy pathrun.bat
File metadata and controls
113 lines (103 loc) · 4.34 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
@echo off
setlocal EnableExtensions EnableDelayedExpansion
echo ========================================
echo Starting TTS-Story
echo ========================================
echo.
echo NOTE: First startup can pause while models initialize and caches build.
echo Subsequent runs should be faster.
echo.
echo Quick Troubleshooting:
echo - If startup fails, delete the "venv" folder and re-run install-update.bat
echo - GPU users: update to the latest NVIDIA drivers
echo - Run install-update.bat to pull the latest updates
echo.
REM Check if venv exists
if not exist "venv\Scripts\activate.bat" (
echo ERROR: Virtual environment not found
echo Please run setup.bat first
pause
exit /b 1
)
REM Ensure FFmpeg is on PATH if bundled
set "FFMPEG_EXE=%~dp0tools\ffmpeg\ffmpeg.exe"
if exist "%FFMPEG_EXE%" (
set "PATH=%~dp0tools\ffmpeg;%PATH%"
echo FFmpeg ready: %FFMPEG_EXE%
) else (
echo WARNING: FFmpeg not found (expected %FFMPEG_EXE%)
)
REM Detect NVIDIA GPU (for CPU-only torch fallback)
set "HAS_NVIDIA=0"
set "GPU_NAME="
for /f "delims=" %%G in ('powershell -NoLogo -NoProfile -Command "$g=(Get-CimInstance Win32_VideoController | Where-Object { $_.Name -match 'NVIDIA' } | Select-Object -First 1).Name; if ($g) { $g }"') do set "GPU_NAME=%%G"
if defined GPU_NAME (
set "HAS_NVIDIA=1"
)
REM Activate virtual environment
call venv\Scripts\activate.bat
REM Ensure CPU-only torch on systems without NVIDIA GPUs
if "%SKIP_TORCH_INSTALL%"=="1" (
echo SKIP_TORCH_INSTALL=1 set. Skipping torch checks.
) else if "%HAS_NVIDIA%"=="0" (
set "TORCH_PIN=2.6.0"
set "TORCHVISION_PIN=0.21.0"
set "TORCHAUDIO_PIN=2.6.0"
set "TORCH_INSTALLED="
for /f "delims=" %%V in ('python -c "import torch, sys; sys.stdout.write(torch.__version__)" 2^>nul') do set "TORCH_INSTALLED=%%V"
if "%FORCE_TORCH_REINSTALL%"=="1" (
echo FORCE_TORCH_REINSTALL=1 set. Reinstalling CPU-only torch...
pip uninstall -y torch torchvision torchaudio >nul 2>&1
pip install --upgrade --force-reinstall torch==!TORCH_PIN!+cpu torchvision==!TORCHVISION_PIN!+cpu torchaudio==!TORCHAUDIO_PIN!+cpu --index-url https://download.pytorch.org/whl/cpu
pip install --upgrade "numpy<1.26.0" "pillow<12.0" "fsspec<=2025.3.0" "filelock>=3.20.1,<4"
) else if not defined TORCH_INSTALLED (
echo WARNING: PyTorch failed to import. Reinstalling CPU-only torch...
pip uninstall -y torch torchvision torchaudio >nul 2>&1
pip install --upgrade --force-reinstall torch==!TORCH_PIN!+cpu torchvision==!TORCHVISION_PIN!+cpu torchaudio==!TORCHAUDIO_PIN!+cpu --index-url https://download.pytorch.org/whl/cpu
pip install --upgrade "numpy<1.26.0" "pillow<12.0" "fsspec<=2025.3.0" "filelock>=3.20.1,<4"
) else (
echo Detected PyTorch: !TORCH_INSTALLED!
echo !TORCH_INSTALLED! | findstr /i "+cu" >nul 2>&1
if not errorlevel 1 (
echo CUDA build detected on CPU-only system. Reinstalling CPU-only torch...
pip uninstall -y torch torchvision torchaudio >nul 2>&1
pip install --upgrade --force-reinstall torch==!TORCH_PIN!+cpu torchvision==!TORCHVISION_PIN!+cpu torchaudio==!TORCHAUDIO_PIN!+cpu --index-url https://download.pytorch.org/whl/cpu
pip install --upgrade "numpy<1.26.0" "pillow<12.0" "fsspec<=2025.3.0" "filelock>=3.20.1,<4"
)
)
)
REM Ensure Rubber Band CLI is on PATH if bundled
set "RB_EXE=%~dp0tools\rubberband\rubberband.exe"
if exist "%RB_EXE%" (
set "PATH=%~dp0tools\rubberband;%PATH%"
echo Rubber Band CLI ready: %RB_EXE%
) else (
echo WARNING: Rubber Band CLI not found (expected %RB_EXE%)
)
REM Ensure SoX is on PATH if bundled
set "SOX_EXE=%~dp0tools\sox\sox.exe"
if exist "%SOX_EXE%" (
set "PATH=%~dp0tools\sox;%PATH%"
echo SoX ready: %SOX_EXE%
) else (
echo WARNING: SoX not found (expected %SOX_EXE%)
)
REM Skip CUDA check at startup (can hang on some systems)
REM CUDA availability will be detected when the app starts
echo.
echo Starting Flask server...
echo Open your browser to: http://localhost:5000
echo Press Ctrl+C to stop the server
echo.
REM Start the application
set "TTS_STORY_RESTARTABLE=1"
:run_server
python app.py
set "SERVER_EXIT_CODE=!errorlevel!"
if "!SERVER_EXIT_CODE!"=="75" (
echo.
echo Restart requested. Relaunching TTS-Story backend...
set "TTS_STORY_SKIP_BROWSER=1"
goto run_server
)
exit /b !SERVER_EXIT_CODE!