lollms-client 1.6.0__py3-none-any.whl → 1.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lollms-client might be problematic. Click here for more details.
- lollms_client/__init__.py +1 -1
- lollms_client/lollms_core.py +286 -281
- lollms_client/lollms_tts_binding.py +15 -13
- lollms_client/tts_bindings/xtts/__init__.py +90 -37
- lollms_client/tts_bindings/xtts/server/main.py +282 -279
- {lollms_client-1.6.0.dist-info → lollms_client-1.6.2.dist-info}/METADATA +5 -2
- {lollms_client-1.6.0.dist-info → lollms_client-1.6.2.dist-info}/RECORD +10 -10
- {lollms_client-1.6.0.dist-info → lollms_client-1.6.2.dist-info}/WHEEL +0 -0
- {lollms_client-1.6.0.dist-info → lollms_client-1.6.2.dist-info}/licenses/LICENSE +0 -0
- {lollms_client-1.6.0.dist-info → lollms_client-1.6.2.dist-info}/top_level.txt +0 -0
|
@@ -1,314 +1,317 @@
|
|
|
1
|
-
import uvicorn
|
|
2
|
-
from fastapi import FastAPI, APIRouter, HTTPException
|
|
3
|
-
from pydantic import BaseModel
|
|
4
|
-
import argparse
|
|
5
|
-
import sys
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
import asyncio
|
|
8
|
-
import traceback
|
|
9
|
-
import os
|
|
10
|
-
from typing import Optional, List
|
|
11
|
-
import io
|
|
12
|
-
import wave
|
|
13
|
-
import numpy as np
|
|
14
|
-
import tempfile
|
|
15
|
-
|
|
16
|
-
# --- XTTS Implementation ---
|
|
17
1
|
try:
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
print(f"Server: Traceback:\n{traceback.format_exc()}")
|
|
33
|
-
xtts_available = False
|
|
34
|
-
|
|
35
|
-
# --- API Models ---
|
|
36
|
-
class GenerationRequest(BaseModel):
|
|
37
|
-
text: str
|
|
38
|
-
voice: Optional[str] = None
|
|
39
|
-
language: Optional[str] = "en"
|
|
40
|
-
speaker_wav: Optional[str] = None
|
|
2
|
+
import uvicorn
|
|
3
|
+
from fastapi import FastAPI, APIRouter, HTTPException
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import asyncio
|
|
9
|
+
import traceback
|
|
10
|
+
import os
|
|
11
|
+
from typing import Optional, List
|
|
12
|
+
import io
|
|
13
|
+
import wave
|
|
14
|
+
import numpy as np
|
|
15
|
+
import tempfile
|
|
41
16
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
17
|
+
# --- XTTS Implementation ---
|
|
18
|
+
try:
|
|
19
|
+
print("Server: Loading XTTS dependencies...")
|
|
20
|
+
import torch
|
|
21
|
+
import torchaudio
|
|
22
|
+
from TTS.api import TTS
|
|
23
|
+
print("Server: XTTS dependencies loaded successfully")
|
|
49
24
|
|
|
50
|
-
#
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
# Initialize XTTS model
|
|
72
|
-
self.model = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
|
73
|
-
|
|
74
|
-
self.model_loaded = True
|
|
75
|
-
print("Server: XTTS model loaded successfully")
|
|
76
|
-
|
|
77
|
-
except Exception as e:
|
|
78
|
-
print(f"Server: Error loading XTTS model: {e}")
|
|
79
|
-
print(f"Server: Traceback:\n{traceback.format_exc()}")
|
|
25
|
+
# Check for CUDA availability
|
|
26
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
27
|
+
print(f"Server: Using device: {device}")
|
|
28
|
+
|
|
29
|
+
xtts_available = True
|
|
30
|
+
|
|
31
|
+
except Exception as e:
|
|
32
|
+
print(f"Server: Failed to load XTTS dependencies: {e}")
|
|
33
|
+
print(f"Server: Traceback:\n{traceback.format_exc()}")
|
|
34
|
+
xtts_available = False
|
|
35
|
+
|
|
36
|
+
# --- API Models ---
|
|
37
|
+
class GenerationRequest(BaseModel):
|
|
38
|
+
text: str
|
|
39
|
+
voice: Optional[str] = None
|
|
40
|
+
language: Optional[str] = "en"
|
|
41
|
+
speaker_wav: Optional[str] = None
|
|
42
|
+
|
|
43
|
+
class XTTSServer:
|
|
44
|
+
def __init__(self):
|
|
45
|
+
self.model = None
|
|
80
46
|
self.model_loaded = False
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
self.
|
|
84
|
-
|
|
85
|
-
def _load_available_voices(self) -> List[str]:
|
|
86
|
-
"""Load and return available voices"""
|
|
87
|
-
try:
|
|
88
|
-
# Look for voice files in voices directory
|
|
89
|
-
voices_dir = Path(__file__).parent / "voices"
|
|
90
|
-
voices = []
|
|
47
|
+
self.model_loading = False # Flag to prevent concurrent loading
|
|
48
|
+
self.available_voices = self._load_available_voices()
|
|
49
|
+
self.available_models = ["xtts_v2"]
|
|
91
50
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
voices = ["default", "female", "male"]
|
|
51
|
+
# Don't initialize model here - do it lazily on first request
|
|
52
|
+
print("Server: XTTS server initialized (model will be loaded on first request)")
|
|
53
|
+
|
|
54
|
+
async def _ensure_model_loaded(self):
|
|
55
|
+
"""Ensure the XTTS model is loaded (lazy loading)"""
|
|
56
|
+
if self.model_loaded:
|
|
57
|
+
return
|
|
100
58
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
59
|
+
if self.model_loading:
|
|
60
|
+
# Another request is already loading the model, wait for it
|
|
61
|
+
while self.model_loading and not self.model_loaded:
|
|
62
|
+
await asyncio.sleep(0.1)
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
if not xtts_available:
|
|
66
|
+
raise RuntimeError("XTTS library not available")
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
self.model_loading = True
|
|
70
|
+
print("Server: Loading XTTS model for the first time (this may take a few minutes)...")
|
|
71
|
+
|
|
72
|
+
# Initialize XTTS model
|
|
73
|
+
self.model = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
|
|
74
|
+
|
|
75
|
+
self.model_loaded = True
|
|
76
|
+
print("Server: XTTS model loaded successfully")
|
|
77
|
+
|
|
78
|
+
except Exception as e:
|
|
79
|
+
print(f"Server: Error loading XTTS model: {e}")
|
|
80
|
+
print(f"Server: Traceback:\n{traceback.format_exc()}")
|
|
81
|
+
self.model_loaded = False
|
|
82
|
+
raise
|
|
83
|
+
finally:
|
|
84
|
+
self.model_loading = False
|
|
112
85
|
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
def _load_available_voices(self) -> List[str]:
|
|
87
|
+
"""Load and return available voices"""
|
|
88
|
+
try:
|
|
89
|
+
# Look for voice files in voices directory
|
|
90
|
+
voices_dir = Path(__file__).parent / "voices"
|
|
91
|
+
voices = []
|
|
92
|
+
|
|
93
|
+
if voices_dir.exists():
|
|
94
|
+
# Look for WAV files in voices directory
|
|
95
|
+
for voice_file in voices_dir.glob("*.wav"):
|
|
96
|
+
voices.append(voice_file.stem)
|
|
97
|
+
|
|
98
|
+
# If no custom voices found, provide some default names
|
|
99
|
+
if not voices:
|
|
100
|
+
voices = ["default", "female", "male"]
|
|
101
|
+
|
|
102
|
+
return voices
|
|
103
|
+
|
|
104
|
+
except Exception as e:
|
|
105
|
+
print(f"Server: Error loading voices: {e}")
|
|
106
|
+
return ["default"]
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
speaker_wav_path = None
|
|
122
|
-
|
|
123
|
-
# First priority: use provided speaker_wav parameter
|
|
124
|
-
if speaker_wav:
|
|
125
|
-
speaker_wav_path = speaker_wav
|
|
126
|
-
print(f"Server: Using provided speaker_wav: {speaker_wav_path}")
|
|
108
|
+
async def generate_audio(self, text: str, voice: Optional[str] = None,
|
|
109
|
+
language: str = "en", speaker_wav: Optional[str] = None) -> bytes:
|
|
110
|
+
"""Generate audio from text using XTTS"""
|
|
111
|
+
# Ensure model is loaded before proceeding
|
|
112
|
+
await self._ensure_model_loaded()
|
|
127
113
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if os.path.exists(voice):
|
|
131
|
-
# Voice parameter is a full file path
|
|
132
|
-
speaker_wav_path = voice
|
|
133
|
-
print(f"Server: Using voice as file path: {speaker_wav_path}")
|
|
134
|
-
else:
|
|
135
|
-
# Look for voice file in voices directory
|
|
136
|
-
voices_dir = Path(__file__).parent / "voices"
|
|
137
|
-
potential_voice_path = voices_dir / f"{voice}.wav"
|
|
138
|
-
if potential_voice_path.exists():
|
|
139
|
-
speaker_wav_path = str(potential_voice_path)
|
|
140
|
-
print(f"Server: Using custom voice file: {speaker_wav_path}")
|
|
141
|
-
else:
|
|
142
|
-
print(f"Server: Voice '{voice}' not found in voices directory")
|
|
143
|
-
|
|
144
|
-
# Create a temporary file for output
|
|
145
|
-
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
|
|
146
|
-
temp_output_path = temp_file.name
|
|
114
|
+
if not self.model_loaded or self.model is None:
|
|
115
|
+
raise RuntimeError("XTTS model failed to load")
|
|
147
116
|
|
|
148
117
|
try:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if
|
|
163
|
-
|
|
118
|
+
print(f"Server: Generating audio for: '{text[:50]}{'...' if len(text) > 50 else ''}'")
|
|
119
|
+
print(f"Server: Using voice: {voice}, language: {language}")
|
|
120
|
+
|
|
121
|
+
# Handle voice/speaker selection
|
|
122
|
+
speaker_wav_path = None
|
|
123
|
+
|
|
124
|
+
# First priority: use provided speaker_wav parameter
|
|
125
|
+
if speaker_wav:
|
|
126
|
+
speaker_wav_path = speaker_wav
|
|
127
|
+
print(f"Server: Using provided speaker_wav: {speaker_wav_path}")
|
|
128
|
+
|
|
129
|
+
# Second priority: check if voice parameter is a file path
|
|
130
|
+
elif voice and voice != "default":
|
|
131
|
+
if os.path.exists(voice):
|
|
132
|
+
# Voice parameter is a full file path
|
|
133
|
+
speaker_wav_path = voice
|
|
134
|
+
print(f"Server: Using voice as file path: {speaker_wav_path}")
|
|
135
|
+
else:
|
|
136
|
+
# Look for voice file in voices directory
|
|
137
|
+
voices_dir = Path(__file__).parent / "voices"
|
|
138
|
+
potential_voice_path = voices_dir / f"{voice}.wav"
|
|
139
|
+
if potential_voice_path.exists():
|
|
140
|
+
speaker_wav_path = str(potential_voice_path)
|
|
141
|
+
print(f"Server: Using custom voice file: {speaker_wav_path}")
|
|
142
|
+
else:
|
|
143
|
+
print(f"Server: Voice '{voice}' not found in voices directory")
|
|
144
|
+
|
|
145
|
+
# Create a temporary file for output
|
|
146
|
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
|
|
147
|
+
temp_output_path = temp_file.name
|
|
148
|
+
|
|
149
|
+
try:
|
|
150
|
+
# Generate audio using XTTS
|
|
151
|
+
if speaker_wav_path and os.path.exists(speaker_wav_path):
|
|
152
|
+
print(f"Server: Generating with speaker reference: {speaker_wav_path}")
|
|
164
153
|
self.model.tts_to_file(
|
|
165
154
|
text=text,
|
|
166
|
-
speaker_wav=
|
|
155
|
+
speaker_wav=speaker_wav_path,
|
|
167
156
|
language=language,
|
|
168
157
|
file_path=temp_output_path
|
|
169
158
|
)
|
|
170
159
|
else:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
160
|
+
print("Server: No valid speaker reference found, trying default")
|
|
161
|
+
# For XTTS without speaker reference, try to find a default
|
|
162
|
+
default_speaker = self._get_default_speaker_file()
|
|
163
|
+
if default_speaker and os.path.exists(default_speaker):
|
|
164
|
+
print(f"Server: Using default speaker: {default_speaker}")
|
|
165
|
+
self.model.tts_to_file(
|
|
166
|
+
text=text,
|
|
167
|
+
speaker_wav=default_speaker,
|
|
168
|
+
language=language,
|
|
169
|
+
file_path=temp_output_path
|
|
170
|
+
)
|
|
171
|
+
else:
|
|
172
|
+
# Create a more helpful error message
|
|
173
|
+
available_voices = self._get_all_available_voice_files()
|
|
174
|
+
error_msg = f"No speaker reference available. XTTS requires a speaker reference file.\n"
|
|
175
|
+
error_msg += f"Attempted to use: {speaker_wav_path if speaker_wav_path else 'None'}\n"
|
|
176
|
+
error_msg += f"Available voice files: {available_voices}"
|
|
177
|
+
raise RuntimeError(error_msg)
|
|
178
|
+
|
|
179
|
+
# Read the generated audio file
|
|
180
|
+
with open(temp_output_path, 'rb') as f:
|
|
181
|
+
audio_bytes = f.read()
|
|
182
|
+
|
|
183
|
+
print(f"Server: Generated {len(audio_bytes)} bytes of audio")
|
|
184
|
+
return audio_bytes
|
|
185
|
+
|
|
186
|
+
finally:
|
|
187
|
+
# Clean up temporary file
|
|
188
|
+
if os.path.exists(temp_output_path):
|
|
189
|
+
os.unlink(temp_output_path)
|
|
184
190
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
except Exception as e:
|
|
191
|
-
print(f"Server: Error generating audio: {e}")
|
|
192
|
-
print(f"Server: Traceback:\n{traceback.format_exc()}")
|
|
193
|
-
raise
|
|
194
|
-
|
|
195
|
-
def _get_all_available_voice_files(self) -> List[str]:
|
|
196
|
-
"""Get list of all available voice files for debugging"""
|
|
197
|
-
voices_dir = Path(__file__).parent / "voices"
|
|
198
|
-
voice_files = []
|
|
191
|
+
except Exception as e:
|
|
192
|
+
print(f"Server: Error generating audio: {e}")
|
|
193
|
+
print(f"Server: Traceback:\n{traceback.format_exc()}")
|
|
194
|
+
raise
|
|
199
195
|
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
def _get_all_available_voice_files(self) -> List[str]:
|
|
197
|
+
"""Get list of all available voice files for debugging"""
|
|
198
|
+
voices_dir = Path(__file__).parent / "voices"
|
|
199
|
+
voice_files = []
|
|
202
200
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
voices_dir = Path(__file__).parent / "voices"
|
|
201
|
+
if voices_dir.exists():
|
|
202
|
+
voice_files = [str(f) for f in voices_dir.glob("*.wav")]
|
|
203
|
+
|
|
204
|
+
return voice_files
|
|
208
205
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
def _get_default_speaker_file(self) -> Optional[str]:
|
|
207
|
+
"""Get path to default speaker file"""
|
|
208
|
+
voices_dir = Path(__file__).parent / "voices"
|
|
209
|
+
|
|
210
|
+
# Look for a default speaker file
|
|
211
|
+
for filename in ["default.wav", "speaker.wav", "reference.wav"]:
|
|
212
|
+
potential_path = voices_dir / filename
|
|
213
|
+
if potential_path.exists():
|
|
214
|
+
return str(potential_path)
|
|
215
|
+
|
|
216
|
+
# If no default found, look for any wav file
|
|
217
|
+
wav_files = list(voices_dir.glob("*.wav"))
|
|
218
|
+
if wav_files:
|
|
219
|
+
return str(wav_files[0])
|
|
220
|
+
|
|
221
|
+
return None
|
|
214
222
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return str(wav_files[0])
|
|
223
|
+
def list_voices(self) -> List[str]:
|
|
224
|
+
"""Return list of available voices"""
|
|
225
|
+
return self.available_voices
|
|
219
226
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"""Return list of available voices"""
|
|
224
|
-
return self.available_voices
|
|
225
|
-
|
|
226
|
-
def list_models(self) -> List[str]:
|
|
227
|
-
"""Return list of available models"""
|
|
228
|
-
return self.available_models
|
|
227
|
+
def list_models(self) -> List[str]:
|
|
228
|
+
"""Return list of available models"""
|
|
229
|
+
return self.available_models
|
|
229
230
|
|
|
230
|
-
# --- Globals ---
|
|
231
|
-
app = FastAPI(title="XTTS Server")
|
|
232
|
-
router = APIRouter()
|
|
233
|
-
xtts_server = XTTSServer()
|
|
234
|
-
model_lock = asyncio.Lock() # Ensure thread-safe access
|
|
231
|
+
# --- Globals ---
|
|
232
|
+
app = FastAPI(title="XTTS Server")
|
|
233
|
+
router = APIRouter()
|
|
234
|
+
xtts_server = XTTSServer()
|
|
235
|
+
model_lock = asyncio.Lock() # Ensure thread-safe access
|
|
236
|
+
|
|
237
|
+
# --- API Endpoints ---
|
|
238
|
+
@router.post("/generate_audio")
|
|
239
|
+
async def generate_audio(request: GenerationRequest):
|
|
240
|
+
async with model_lock:
|
|
241
|
+
try:
|
|
242
|
+
audio_bytes = await xtts_server.generate_audio(
|
|
243
|
+
text=request.text,
|
|
244
|
+
voice=request.voice,
|
|
245
|
+
language=request.language,
|
|
246
|
+
speaker_wav=request.speaker_wav
|
|
247
|
+
)
|
|
248
|
+
from fastapi.responses import Response
|
|
249
|
+
return Response(content=audio_bytes, media_type="audio/wav")
|
|
250
|
+
except Exception as e:
|
|
251
|
+
print(f"Server: ERROR in generate_audio endpoint: {e}")
|
|
252
|
+
print(f"Server: ERROR traceback:\n{traceback.format_exc()}")
|
|
253
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
235
254
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
async def generate_audio(request: GenerationRequest):
|
|
239
|
-
async with model_lock:
|
|
255
|
+
@router.get("/list_voices")
|
|
256
|
+
async def list_voices():
|
|
240
257
|
try:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
language=request.language,
|
|
245
|
-
speaker_wav=request.speaker_wav
|
|
246
|
-
)
|
|
247
|
-
from fastapi.responses import Response
|
|
248
|
-
return Response(content=audio_bytes, media_type="audio/wav")
|
|
258
|
+
voices = xtts_server.list_voices()
|
|
259
|
+
print(f"Server: Returning {len(voices)} voices: {voices}")
|
|
260
|
+
return {"voices": voices}
|
|
249
261
|
except Exception as e:
|
|
250
|
-
print(f"Server: ERROR in
|
|
262
|
+
print(f"Server: ERROR in list_voices endpoint: {e}")
|
|
251
263
|
print(f"Server: ERROR traceback:\n{traceback.format_exc()}")
|
|
252
264
|
raise HTTPException(status_code=500, detail=str(e))
|
|
253
265
|
|
|
254
|
-
@router.get("/
|
|
255
|
-
async def
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
@router.get("/list_models")
|
|
266
|
-
async def list_models():
|
|
267
|
-
try:
|
|
268
|
-
models = xtts_server.list_models()
|
|
269
|
-
print(f"Server: Returning {len(models)} models: {models}")
|
|
270
|
-
return {"models": models}
|
|
271
|
-
except Exception as e:
|
|
272
|
-
print(f"Server: ERROR in list_models endpoint: {e}")
|
|
273
|
-
print(f"Server: ERROR traceback:\n{traceback.format_exc()}")
|
|
274
|
-
raise HTTPException(status_code=500, detail=str(e))
|
|
266
|
+
@router.get("/list_models")
|
|
267
|
+
async def list_models():
|
|
268
|
+
try:
|
|
269
|
+
models = xtts_server.list_models()
|
|
270
|
+
print(f"Server: Returning {len(models)} models: {models}")
|
|
271
|
+
return {"models": models}
|
|
272
|
+
except Exception as e:
|
|
273
|
+
print(f"Server: ERROR in list_models endpoint: {e}")
|
|
274
|
+
print(f"Server: ERROR traceback:\n{traceback.format_exc()}")
|
|
275
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
275
276
|
|
|
276
|
-
@router.get("/status")
|
|
277
|
-
async def status():
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
277
|
+
@router.get("/status")
|
|
278
|
+
async def status():
|
|
279
|
+
return {
|
|
280
|
+
"status": "running",
|
|
281
|
+
"xtts_available": xtts_available,
|
|
282
|
+
"model_loaded": xtts_server.model_loaded,
|
|
283
|
+
"model_loading": xtts_server.model_loading,
|
|
284
|
+
"voices_count": len(xtts_server.available_voices),
|
|
285
|
+
"device": torch.cuda.get_device_name(0) if torch.cuda.is_available() else "CPU"
|
|
286
|
+
}
|
|
286
287
|
|
|
287
|
-
# Add a health check endpoint that responds immediately
|
|
288
|
-
@router.get("/health")
|
|
289
|
-
async def health_check():
|
|
290
|
-
|
|
288
|
+
# Add a health check endpoint that responds immediately
|
|
289
|
+
@router.get("/health")
|
|
290
|
+
async def health_check():
|
|
291
|
+
return {"status": "healthy", "ready": True}
|
|
291
292
|
|
|
292
|
-
app.include_router(router)
|
|
293
|
+
app.include_router(router)
|
|
293
294
|
|
|
294
|
-
# --- Server Startup ---
|
|
295
|
-
if __name__ == '__main__':
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
295
|
+
# --- Server Startup ---
|
|
296
|
+
if __name__ == '__main__':
|
|
297
|
+
parser = argparse.ArgumentParser(description="XTTS TTS Server")
|
|
298
|
+
parser.add_argument("--host", type=str, default="localhost", help="Host to bind the server to.")
|
|
299
|
+
parser.add_argument("--port", type=int, default="8081", help="Port to bind the server to.")
|
|
300
|
+
|
|
301
|
+
args = parser.parse_args()
|
|
301
302
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
303
|
+
print(f"Server: Starting XTTS server on {args.host}:{args.port}")
|
|
304
|
+
print(f"Server: XTTS available: {xtts_available}")
|
|
305
|
+
print(f"Server: Model will be loaded on first audio generation request")
|
|
306
|
+
print(f"Server: Available voices: {len(xtts_server.available_voices)}")
|
|
307
|
+
if xtts_available:
|
|
308
|
+
print(f"Server: Device: {torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU'}")
|
|
309
|
+
|
|
310
|
+
# Create voices directory if it doesn't exist
|
|
311
|
+
voices_dir = Path(__file__).parent / "voices"
|
|
312
|
+
voices_dir.mkdir(exist_ok=True)
|
|
313
|
+
print(f"Server: Voices directory: {voices_dir}")
|
|
314
|
+
|
|
315
|
+
uvicorn.run(app, host=args.host, port=args.port)
|
|
316
|
+
except Exception as e:
|
|
317
|
+
print(f"Server: CRITICAL ERROR during startup: {e}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lollms_client
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.2
|
|
4
4
|
Summary: A client library for LoLLMs generate endpoint
|
|
5
5
|
Author-email: ParisNeo <parisneoai@gmail.com>
|
|
6
6
|
License: Apache License
|
|
@@ -1302,6 +1302,7 @@ try:
|
|
|
1302
1302
|
except Exception as e:
|
|
1303
1303
|
ASCIIColors.error(f"Error initializing Hugging Face Inference API binding: {e}")
|
|
1304
1304
|
ASCIIColors.info("Please ensure your Hugging Face API token is correctly set and you have access to the specified model.")```
|
|
1305
|
+
```
|
|
1305
1306
|
|
|
1306
1307
|
---
|
|
1307
1308
|
|
|
@@ -1403,7 +1404,9 @@ else:
|
|
|
1403
1404
|
|
|
1404
1405
|
except Exception as e:
|
|
1405
1406
|
ASCIIColors.error(f"An error occurred during multi-image fusion: {e}")
|
|
1406
|
-
```
|
|
1407
|
+
```
|
|
1408
|
+
|
|
1409
|
+
This powerful feature allows for complex creative tasks like character swapping, background replacement, and style transfer directly through the `lollms_client` library.
|
|
1407
1410
|
|
|
1408
1411
|
### Listing Available Models
|
|
1409
1412
|
|