chatterbox icon indicating copy to clipboard operation
chatterbox copied to clipboard

TypeError: 'NoneType' object is not callable when initializing ChatterboxTTS

Open biraj-outspeed opened this issue 5 months ago • 12 comments

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-tts installed 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.

biraj-outspeed avatar Jul 16 '25 12:07 biraj-outspeed

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.

EvansJahja avatar Jul 17 '25 08:07 EvansJahja

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 avatar Jul 17 '25 12:07 biraj-outspeed

@biraj-outspeed, I am having the same issue when using uv pip install. Can anyone help me build from source?

BennisonDevadoss avatar Jul 29 '25 08:07 BennisonDevadoss

@biraj-outspeed, I tried it using the source, still having the same issue.

BennisonDevadoss avatar Jul 29 '25 08:07 BennisonDevadoss

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 avatar Aug 07 '25 23:08 gvxcode

@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.

BambinoPinguino avatar Sep 02 '25 04:09 BambinoPinguino

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?

onakatomi avatar Oct 16 '25 00:10 onakatomi

https://github.com/resemble-ai/Perth/issues/7 the workaround here is working, just install setuptools beforehand then pip install

boltomli avatar Nov 04 '25 03:11 boltomli

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.

tsuus avatar Nov 07 '25 13:11 tsuus

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!

stevelittlefish avatar Nov 13 '25 14:11 stevelittlefish