TypeError: 'NoneType' object is not callable when initializing ChatterboxTTS
TypeError: 'NoneType' object is not callable when initializing ChatterboxTTS
Environment
- Setup via uv.
- Python 3.11
- AWS g5.2xlarge instance (A10G GPU)
- Ubuntu with CUDA available
chatterbox-ttsinstalled via uv.
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0
Issue
ChatterboxTTS.from_pretrained() fails with TypeError: 'NoneType' object is not callable
Error Traceback
Using device: cuda
/home/ubuntu/biraj/chatterbox/.venv/lib/python3.11/site-packages/diffusers/models/lora.py:393: FutureWarning: `LoRACompatibleLinear` is deprecated and will be removed in version 1.0.0. Use of `LoRACompatibleLinear` is deprecated. Please switch to PEFT backend by installing PEFT: `pip install peft`.
deprecate("LoRACompatibleLinear", "1.0.0", deprecation_message)
Traceback (most recent call last):
File "/home/ubuntu/biraj/chatterbox/main.py", line 15, in <module>
model = ChatterboxTTS.from_pretrained(device=device) # this is failing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/biraj/chatterbox/.venv/lib/python3.11/site-packages/chatterbox/tts.py", line 180, in from_pretrained
return cls.from_local(Path(local_path).parent, device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/biraj/chatterbox/.venv/lib/python3.11/site-packages/chatterbox/tts.py", line 165, in from_local
return cls(t3, s3gen, ve, tokenizer, device, conds=conds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/biraj/chatterbox/.venv/lib/python3.11/site-packages/chatterbox/tts.py", line 126, in __init__
self.watermarker = perth.PerthImplicitWatermarker()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable
Code
import torch
import torchaudio as ta
from chatterbox.tts import ChatterboxTTS
# Automatically detect the best available device
if torch.cuda.is_available():
device = "cuda"
elif torch.backends.mps.is_available():
device = "mps"
else:
device = "cpu"
print(f"Using device: {device}")
model = ChatterboxTTS.from_pretrained(device=device) # this is failing
text = "Ezreal and Jinx teamed up with Ahri, Yasuo, and Teemo to take down the enemy's Nexus in an epic late-game pentakill."
wav = model.generate(text)
ta.save("test-1.wav", wav, model.sr)
Investigation
The issue appears to be with the perth library. While perth is installed and importable, perth.PerthImplicitWatermarker returns None:
Investigation code:
import perth
print(dir(perth))
print(perth.PerthImplicitWatermarker)
output:
['DummyWatermarker', 'PerthImplicitWatermarker', 'WatermarkerBase', 'WatermarkingException', '__all__', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'dummy_watermarker', 'watermarker']
None
As you can see, PerthImplicitWatermarker shows up on dir(perth), but is None when accessed.
I also faced the same issue when I ran the mac example on my macbook with M3.
I encounter the same issue. I'm trying a workaround to replace it with
self.watermarker = perth.DummyWatermarker()
Seems like there's some dependency of perth that's not installed but I can't figure it out quite yet.
i was getting this error only when i installed chatterbox-tts using uv pip install. i built from source and it worked just fine without making any change to the source code.
@biraj-outspeed, I am having the same issue when using uv pip install. Can anyone help me build from source?
@biraj-outspeed, I tried it using the source, still having the same issue.
As a work around I removed the water marking.
tts.py Comment out (Line 126): self.watermarker = perth.PerthImplicitWatermarker() Comment out (Line 271): watermarked_wav = self.watermarker.apply_watermark(wav, sample_rate=self.sr) Update code to return the wav (Line 272): torch.from_numpy(wav).unsqueeze(0)
@gvxcode Thanks a ton, I was pulling my hair out trying to get Chatterbox running and after hours with no luck, this fixed it immediately.
Getting the same issue with uv for a different model (neutts). If I use conda there's no issues.
Any insight as to why uv doesn't like this?
https://github.com/resemble-ai/Perth/issues/7 the workaround here is working, just install setuptools beforehand then pip install
I encounter the same issue. I'm trying a workaround to replace it with
self.watermarker = perth.DummyWatermarker()Seems like there's some dependency of perth that's not installed but I can't figure it out quite yet.
This works for me. Mate, you are a genius.
I know this is an old thread but this is another workaround:
class FakeWatermarker:
def apply_watermark(self, wav, *args, **kwargs):
return wav
# Stupid Monkeypatch thing
perth.PerthImplicitWatermarker = FakeWatermarker
Basically just create the watermarker yourself and make it do nothing!