TTS: [Bug] Cant load xtts

Describe the bug

Error when loading xtts model

To Reproduce

from TTS.api import TTS
model = TTS("xtts", gpu=True)

Expected behavior

Expect it to load model without throwing an error

Logs

raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
        (1) Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
        (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
        WeightsUnpickler error: Unsupported global: GLOBAL TTS.tts.configs.xtts_config.XttsConfig was not an allowed global by default. Please use `torch.serialization.add_safe_globals([XttsConfig])` or the `torch.serialization.safe_globals([XttsConfig])` context manager to allowlist this global if you trust this class/function.
111

Environment

{
    "CUDA": {
        "GPU": [
            "NVIDIA GeForce RTX 3080",
            "NVIDIA GeForce RTX 3080"
        ],
        "available": true,
        "version": "12.4"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.6.0.dev20241119+cu124",
        "TTS": "0.22.0",
        "numpy": "1.22.0"
    },
    "System": {
        "OS": "Linux",
        "architecture": [
            "64bit",
            "ELF"
        ],
        "processor": "x86_64",
        "python": "3.10.14",
        "version": "#1 SMP Thu Jan 11 04:09:03 UTC 2024"
    }
}

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

You should install our fork (via pip install coqui-tts), it should work with the latest Pytorch versions (but I haven’t tested 2.6 yet). This repo is not updated anymore.

The latest version is 0.25.3…

If you don’t want to make a new virtual environment, the best way to switch is:

pip uninstall TTS Trainer coqpit
pip cache purge
pip install -U coqui-tts

Otherwise it can still use the original Trainer and coqpit dependencies instead of their forks.

I had to change io.py locally, adding weights_only flag:

def load_fsspec(
    path: str,
    map_location: Union[str, Callable, torch.device, Dict[Union[str, torch.device], Union[str, torch.device]]] = None,
    cache: bool = True,
    **kwargs,
) -> Any:
    """Like torch.load but can load from other locations (e.g. s3:// , gs://).

    Args:
        path: Any path or url supported by fsspec.
        map_location: torch.device or str.
        cache: If True, cache a remote file locally for subsequent calls. It is cached under `get_user_data_dir()/tts_cache`. Defaults to True.
        **kwargs: Keyword arguments forwarded to torch.load.

    Returns:
        Object stored in path.
    """
    is_local = os.path.isdir(path) or os.path.isfile(path)
    if cache and not is_local:
        with fsspec.open(
            f"filecache::{path}",
            filecache={"cache_storage": str(get_user_data_dir("tts_cache"))},
            mode="rb",
        ) as f:
            return torch.load(f, map_location=map_location, weights_only=False, **kwargs)
    else:
        with fsspec.open(path, "rb") as f:
            return torch.load(f, map_location=map_location, weights_only=False, **kwargs)

I had reinstalled it before:

pip uninstall TTS
pip install coqui-tts

Actually, I found I have:

coqui-tts==0.24.1

Thanks.

@gokturkDev Coqui the company shut down in December 2023, so it is not being sold anymore. We have no affiliation with the original team.