forked from devnen/Chatterbox-TTS-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
209 lines (186 loc) · 6.72 KB
/
start.bat
File metadata and controls
209 lines (186 loc) · 6.72 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
@echo off
REM ============================================================================
REM Chatterbox TTS Server - Windows Launcher
REM ============================================================================
REM Double-click this file to start the Chatterbox TTS Server.
REM This script finds Python and runs start.py with all arguments.
REM The window will stay open on errors so you can read the output.
REM ============================================================================
setlocal enabledelayedexpansion
REM Change to the directory where this batch file is located
cd /d "%~dp0"
echo.
echo ============================================================
echo Chatterbox TTS Server - Launcher
echo ============================================================
echo.
REM Check if start.py exists
if not exist "start.py" (
echo.
echo [ERROR] start.py not found!
echo.
echo Please make sure start.py is in the same folder as this batch file.
echo Current directory: %cd%
echo.
goto :pause_and_exit
)
REM ============================================================================
REM Find Python Installation
REM ============================================================================
echo Checking for Python installation...
echo.
set PYTHON_CMD=
set PYTHON_FOUND=0
REM Try python3 first (common on systems with multiple Python versions)
python3 --version >nul 2>&1
if %errorlevel% equ 0 (
for /f "tokens=*" %%i in ('python3 --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Found !PYTHON_VERSION! ^(python3^)
set PYTHON_CMD=python3
set PYTHON_FOUND=1
goto :check_version
)
REM Try python command
python --version >nul 2>&1
if %errorlevel% equ 0 (
for /f "tokens=*" %%i in ('python --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Found !PYTHON_VERSION! ^(python^)
REM Check if it's Python 3.x
echo !PYTHON_VERSION! | findstr /C:"Python 3." >nul
if !errorlevel! equ 0 (
set PYTHON_CMD=python
set PYTHON_FOUND=1
goto :check_version
) else (
echo [WARNING] Found Python 2.x, looking for Python 3...
)
)
REM Try py launcher (Windows Python Launcher)
py --version >nul 2>&1
if %errorlevel% equ 0 (
REM Try to get Python 3.12 specifically
py -3.12 --version >nul 2>&1
if !errorlevel! equ 0 (
for /f "tokens=*" %%i in ('py -3.12 --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Found !PYTHON_VERSION! ^(py -3.12^)
set PYTHON_CMD=py -3.12
set PYTHON_FOUND=1
goto :check_version
)
REM Try Python 3.11
py -3.11 --version >nul 2>&1
if !errorlevel! equ 0 (
for /f "tokens=*" %%i in ('py -3.11 --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Found !PYTHON_VERSION! ^(py -3.11^)
set PYTHON_CMD=py -3.11
set PYTHON_FOUND=1
goto :check_version
)
REM Try Python 3.10
py -3.10 --version >nul 2>&1
if !errorlevel! equ 0 (
for /f "tokens=*" %%i in ('py -3.10 --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Found !PYTHON_VERSION! ^(py -3.10^)
set PYTHON_CMD=py -3.10
set PYTHON_FOUND=1
goto :check_version
)
REM Fall back to any Python 3
py -3 --version >nul 2>&1
if !errorlevel! equ 0 (
for /f "tokens=*" %%i in ('py -3 --version 2^>^&1') do set PYTHON_VERSION=%%i
echo [OK] Found !PYTHON_VERSION! ^(py -3^)
set PYTHON_CMD=py -3
set PYTHON_FOUND=1
goto :check_version
)
)
REM If we get here, Python was not found
if %PYTHON_FOUND% equ 0 (
echo.
echo ============================================================
echo [ERROR] Python 3.10+ not found!
echo ============================================================
echo.
echo Please install Python 3.10 or newer from:
echo https://www.python.org/downloads/
echo.
echo During installation, make sure to:
echo [x] Check "Add Python to PATH"
echo [x] Check "Install for all users" ^(recommended^)
echo.
echo After installing Python, close this window and try again.
echo.
goto :pause_and_exit
)
:check_version
REM ============================================================================
REM Verify Python version is 3.10+
REM ============================================================================
echo.
echo Verifying Python version...
REM Extract major and minor version numbers
for /f "tokens=2 delims= " %%a in ('!PYTHON_CMD! --version 2^>^&1') do set FULL_VERSION=%%a
for /f "tokens=1,2 delims=." %%a in ("!FULL_VERSION!") do (
set MAJOR=%%a
set MINOR=%%b
)
REM Check if version is at least 3.10
if !MAJOR! LSS 3 (
echo [ERROR] Python 3.10+ required, but found Python !MAJOR!.!MINOR!
goto :version_error
)
if !MAJOR! EQU 3 if !MINOR! LSS 10 (
echo [ERROR] Python 3.10+ required, but found Python !MAJOR!.!MINOR!
goto :version_error
)
echo [OK] Python !MAJOR!.!MINOR! meets requirements ^(3.10+^)
goto :run_script
:version_error
echo.
echo ============================================================
echo [ERROR] Python version too old!
echo ============================================================
echo.
echo Chatterbox TTS Server requires Python 3.10 or newer.
echo Found: Python !MAJOR!.!MINOR!
echo.
echo Please install Python 3.10+ from:
echo https://www.python.org/downloads/
echo.
goto :pause_and_exit
:run_script
REM ============================================================================
REM Run the main Python script
REM ============================================================================
echo.
echo ============================================================
echo Starting Chatterbox TTS Server...
echo ============================================================
echo.
echo Using: !PYTHON_CMD!
echo.
REM Launch Python script with all arguments and wait for it to finish
!PYTHON_CMD! start.py --verbose %*
REM Capture the exit code from Python
set EXIT_CODE=%errorlevel%
REM Show result message based on exit code
echo.
echo ============================================================
if %EXIT_CODE% equ 0 (
echo Server stopped normally.
) else if %EXIT_CODE% equ 1 (
echo Server exited with an error ^(code: %EXIT_CODE%^)
) else if %EXIT_CODE% equ 2 (
echo Installation was cancelled.
) else (
echo Server exited with code: %EXIT_CODE%
)
echo ============================================================
:pause_and_exit
REM Always pause so the user can read any messages
echo.
echo Press any key to close this window...
pause >nul
endlocal
exit /b %EXIT_CODE%