Files
diodiogod-TTS-Audio-Suite/engines/chatterbox/perth_loader.py
diodiogod 1ea6f182fb Version 4.25.6
Fix ChatterBox optional perth import crashing model load on Python 3.13

Technical details:
- Move perth import behind lazy watermark initialization
- Prevent module load from touching fragile librosa resample path by default
- Keep watermarking available only when explicitly enabled
2026-04-10 21:43:54 -03:00

24 lines
739 B
Python

import warnings
def create_perth_watermarker():
"""
Lazily import perth only when watermarking is actually requested.
Watermarking is disabled by default, so Chatterbox should not fail model load
just because perth drags in a fragile librosa import path on some envs.
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore")
import perth
watermarker_cls = getattr(perth, "PerthImplicitWatermarker", None)
if watermarker_cls is None:
raise AttributeError("PerthImplicitWatermarker not available in perth module")
watermarker = watermarker_cls()
if watermarker is None:
raise ValueError("PerthImplicitWatermarker returned None")
return watermarker