fix: XTTS splits long text into sentences before sending (WebSocket size limit)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3461f45207
commit
06bc456221
|
|
@ -851,20 +851,27 @@ class ARIABridge:
|
|||
tts_engine = getattr(self, 'tts_engine_type', 'piper')
|
||||
|
||||
if tts_engine == "xtts":
|
||||
# XTTS: Request ueber RVS an Gaming-PC senden
|
||||
# XTTS: Lange Texte satzweise aufteilen (WebSocket-Limit + schnellere Wiedergabe)
|
||||
import re as _re
|
||||
xtts_voice = getattr(self, 'xtts_voice', '')
|
||||
clean_text = _re.sub(r'\*\*([^*]+)\*\*', r'\1', text).strip()
|
||||
sentences = _re.split(r'(?<=[.!?])\s+', clean_text)
|
||||
sentences = [s.strip() for s in sentences if s.strip()]
|
||||
if not sentences:
|
||||
sentences = [clean_text]
|
||||
try:
|
||||
await self._send_to_rvs({
|
||||
"type": "xtts_request",
|
||||
"payload": {
|
||||
"text": text,
|
||||
"voice": xtts_voice,
|
||||
"language": "de",
|
||||
"requestId": str(uuid.uuid4()),
|
||||
},
|
||||
"timestamp": int(asyncio.get_event_loop().time() * 1000),
|
||||
})
|
||||
logger.info("[core] XTTS-Request gesendet (%s): '%s'", xtts_voice or "default", text[:60])
|
||||
for sentence in sentences:
|
||||
await self._send_to_rvs({
|
||||
"type": "xtts_request",
|
||||
"payload": {
|
||||
"text": sentence,
|
||||
"voice": xtts_voice,
|
||||
"language": "de",
|
||||
"requestId": str(uuid.uuid4()),
|
||||
},
|
||||
"timestamp": int(asyncio.get_event_loop().time() * 1000),
|
||||
})
|
||||
logger.info("[core] XTTS-Request gesendet (%s, %d Saetze): '%s'", xtts_voice or "default", len(sentences), text[:60])
|
||||
except Exception as e:
|
||||
logger.warning("[core] XTTS-Request fehlgeschlagen: %s — Fallback auf Piper", e)
|
||||
# Fallback auf Piper
|
||||
|
|
|
|||
Loading…
Reference in New Issue