Fix ChatTTS CUDA device-side assert with text sanitize and GPU recovery.

Re-enable KV cache by default, normalize digits and unsafe chars, disable per-chunk split_text, and reload ChatTTS after CUDA errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-12 17:13:57 +08:00
parent 1779449bba
commit 8be34a2fd5
4 changed files with 128 additions and 10 deletions
+10
View File
@@ -39,6 +39,13 @@ def _env_int(key: str, default: int) -> int:
return default
def _env_bool(key: str, default: bool) -> bool:
raw = os.environ.get(key)
if raw is None:
return default
return raw.strip().lower() in ("1", "true", "yes", "on")
# ---------------------------------------------------------------------------
# 网络与服务
# ---------------------------------------------------------------------------
@@ -145,6 +152,9 @@ TTS_MAX_NEW_TOKEN = _env_int("TTS_MAX_NEW_TOKEN", 1024)
# 至少生成多少 audio token 才允许结束(防止首 token EOS → 无限递归重试)
TTS_MIN_NEW_TOKEN = _env_int("TTS_MIN_NEW_TOKEN", 16)
# GPT KV cache(关闭可省显存,但部分 transformers 版本会触发 CUDA assert
TTS_ENABLE_CACHE = _env_bool("TTS_ENABLE_CACHE", True)
# ---------------------------------------------------------------------------
# 上传临时文件目录
# ---------------------------------------------------------------------------