diff --git a/README.md b/README.md index 2f8efa2..eb26bad 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ Supports a MAXIMUM of 40 seconds. Iv tried removing this limitation, but the mod pip install -r ComfyUI_Fill-ChatterBox/requirements.txt ``` +3. (Optional) Install watermarking support: + ```bash + pip install resemble-perth + ``` + **Note**: The `resemble-perth` package may have compatibility issues with Python 3.12+. If you encounter import errors, the nodes will still function without watermarking. + ## Usage @@ -37,6 +43,8 @@ Supports a MAXIMUM of 40 seconds. Iv tried removing this limitation, but the mod - Added seed parameter to both TTS and VC nodes for reproducible generation - Seed range: 0 to 4,294,967,295 (32-bit integer) - Enables consistent audio output for debugging and workflow control +- Made Perth watermarking optional to fix Python 3.12+ compatibility issues +- Nodes now function without watermarking if resemble-perth import fails ### 5/31/2025 - Added Persistent model loading, and loading bar functionality diff --git a/local_chatterbox/chatterbox/tts.py b/local_chatterbox/chatterbox/tts.py index 7186a0d..2584656 100644 --- a/local_chatterbox/chatterbox/tts.py +++ b/local_chatterbox/chatterbox/tts.py @@ -3,8 +3,15 @@ from pathlib import Path import librosa import torch -import perth import torch.nn.functional as F + +# Optional Perth watermarking - gracefully handle import failure +try: + import perth + PERTH_AVAILABLE = True +except ImportError: + PERTH_AVAILABLE = False + print("Warning: Perth watermarking not available. Audio will be generated without watermarking.") from huggingface_hub import hf_hub_download from safetensors.torch import load_file @@ -123,7 +130,7 @@ class ChatterboxTTS: self.tokenizer = tokenizer self.device = device self.conds = conds - self.watermarker = perth.PerthImplicitWatermarker() + self.watermarker = perth.PerthImplicitWatermarker() if PERTH_AVAILABLE else None @classmethod def from_local(cls, ckpt_dir, device) -> 'ChatterboxTTS': @@ -259,5 +266,8 @@ class ChatterboxTTS: ref_dict=self.conds.gen, ) wav = wav.squeeze(0).detach().cpu().numpy() - watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr) - return torch.from_numpy(watermarked_wav).unsqueeze(0) \ No newline at end of file + if self.watermarker is not None: + watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr) + return torch.from_numpy(watermarked_wav).unsqueeze(0) + else: + return torch.from_numpy(wav).unsqueeze(0) \ No newline at end of file diff --git a/local_chatterbox/chatterbox/vc.py b/local_chatterbox/chatterbox/vc.py index d2be3da..6508a70 100644 --- a/local_chatterbox/chatterbox/vc.py +++ b/local_chatterbox/chatterbox/vc.py @@ -2,9 +2,16 @@ from pathlib import Path import librosa import torch -import perth from huggingface_hub import hf_hub_download +# Optional Perth watermarking - gracefully handle import failure +try: + import perth + PERTH_AVAILABLE = True +except ImportError: + PERTH_AVAILABLE = False + print("Warning: Perth watermarking not available. Audio will be generated without watermarking.") + from .models.s3tokenizer import S3_SR from .models.s3gen import S3GEN_SR, S3Gen @@ -25,7 +32,7 @@ class ChatterboxVC: self.sr = S3GEN_SR self.s3gen = s3gen self.device = device - self.watermarker = perth.PerthImplicitWatermarker() + self.watermarker = perth.PerthImplicitWatermarker() if PERTH_AVAILABLE else None if ref_dict is None: self.ref_dict = None else: @@ -99,5 +106,8 @@ class ChatterboxVC: ref_dict=self.ref_dict, ) wav = wav.squeeze(0).detach().cpu().numpy() - watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr) - return torch.from_numpy(watermarked_wav).unsqueeze(0) \ No newline at end of file + if self.watermarker is not None: + watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr) + return torch.from_numpy(watermarked_wav).unsqueeze(0) + else: + return torch.from_numpy(wav).unsqueeze(0) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 70519ea..3bff793 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,8 @@ librosa s3tokenizer transformers diffusers -resemble-perth omegaconf conformer -safetensors \ No newline at end of file +safetensors +# Optional watermarking (may have Python 3.12+ compatibility issues) +# resemble-perth \ No newline at end of file