Spaces:
Runtime error
Runtime error verified: the XTTS checkpoint needs four classes allowlisted, not one (completes PR #100)
This Space is in RUNTIME_ERROR, and the cause is confirmed. This post verifies the closest existing fix, shows where it stops, and gives the completed version.
Symptom
On startup, app.py calls model.load_checkpoint(...), which reaches torch.load inside TTS (TTS/utils/io.py, load_fsspec). It fails with:
_pickle.UnpicklingError: Weights only load failed.
Unsupported global: GLOBAL TTS.tts.configs.xtts_config.XttsConfig was not an allowed global by default.
Mechanism
requirements.txt installs TTS v0.21.1 and does not pin torch, so the Space now runs PyTorch 2.6 or later. In PyTorch 2.6 the default of weights_only in torch.load changed from False to True, and TTS v0.21.1's load_fsspec passes no weights_only argument. The XTTS-v2 checkpoint was saved with config objects inside the pickle, so the weights-only unpickler rejects it.
Evidence
The error names only the first class it meets. I scanned the actual checkpoint (coqui/XTTS-v2, model.pth): its model/data.pkl is 203,840 bytes and contains exactly eight GLOBAL entries. Four are allowed by default (collections.OrderedDict and the torch tensor-rebuild/storage helpers). The other four are TTS classes:
TTS.tts.configs.xtts_config.XttsConfigTTS.tts.models.xtts.XttsAudioConfigTTS.config.shared_configs.BaseDatasetConfigTTS.tts.models.xtts.XttsArgs
I then reproduced the load in PyTorch 2.9.1 with a checkpoint built from the same four classes at the same import paths:
- with no allowlist, the load fails naming XttsConfig, exactly as in this Space;
- with only XttsConfig allowlisted, the load fails again, now naming XttsAudioConfig;
- with all four allowlisted, the load succeeds.
That second point matters for PR #100, which allowlists only XttsConfig. It is the right approach and the right place, and it would move the error one class further rather than fixing it. The torch==2.5.1 downgrade proposed in #90 and PR #121 also works around the symptom, at the cost of pinning an old torch and restoring the old default for everything.
Fix
In app.py, extend the existing imports and allowlist all four classes before model.load_checkpoint(...):
from TTS.tts.models.xtts import Xtts, XttsArgs, XttsAudioConfig
from TTS.config.shared_configs import BaseDatasetConfig
model = Xtts.init_from_config(config)
torch.serialization.add_safe_globals(
[XttsConfig, XttsAudioConfig, XttsArgs, BaseDatasetConfig]
)
model.load_checkpoint(
XttsConfig is already imported in app.py. This keeps weights_only=True in force and needs no torch downgrade. The same three names can simply be added to PR #100.
Prove-wrong check
Download model.pth from coqui/XTTS-v2, read model/data.pkl from the zip, and list its GLOBAL opcodes with pickletools: if any TTS class appears there that is not in the four above, this fix is incomplete. Or apply only the one-class allowlist from PR #100 in a duplicate of this Space: if it starts, this analysis is wrong; the reproduction above predicts it fails naming XttsAudioConfig.