Skip to content

Commit a313b34

Browse files
committed
Merge branch 'codex/runtime-models-api'
2 parents 49eae27 + 3cf2035 commit a313b34

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

app/core/tts_model.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,48 @@
1313
os.environ.setdefault("NUMBA_DISABLE_JIT", "1")
1414
os.makedirs(os.environ["NUMBA_CACHE_DIR"], exist_ok=True)
1515

16+
def _patch_perth_watermarker() -> None:
17+
"""
18+
Work around Perth returning `PerthImplicitWatermarker = None`.
19+
20+
This is an upstream compatibility issue that causes Chatterbox model
21+
initialization to fail when it unconditionally calls
22+
`perth.PerthImplicitWatermarker()`.
23+
"""
24+
try:
25+
import perth
26+
except ImportError:
27+
return
28+
29+
perth_watermarker = getattr(perth, "PerthImplicitWatermarker", None)
30+
if callable(perth_watermarker):
31+
return
32+
33+
dummy_watermarker = getattr(perth, "DummyWatermarker", None)
34+
if callable(dummy_watermarker):
35+
perth.PerthImplicitWatermarker = dummy_watermarker
36+
print(
37+
"⚠️ PerthImplicitWatermarker is unavailable; "
38+
"falling back to DummyWatermarker"
39+
)
40+
return
41+
42+
class _PassThroughWatermarker:
43+
def apply_watermark(self, audio, *args, **kwargs):
44+
return audio
45+
46+
def get_watermark(self, *args, **kwargs):
47+
return None
48+
49+
perth.PerthImplicitWatermarker = _PassThroughWatermarker
50+
print(
51+
"⚠️ Perth watermarking is unavailable; "
52+
"using pass-through watermarker fallback"
53+
)
54+
55+
56+
_patch_perth_watermarker()
57+
1658
from chatterbox.tts import ChatterboxTTS
1759
from chatterbox.mtl_tts import ChatterboxMultilingualTTS
1860
from app.core.mtl import SUPPORTED_LANGUAGES

0 commit comments

Comments
 (0)