﻿# XTTS reference caching: retain both GPT conditioning and decoder speaker embedding

Follow the separate conditioning artifacts produced by XTTS reference preparation, and invalidate cached voice data when references, preprocessing, or model revisions change.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-xtts-conditioning-latent-speaker-embedding-cache/
Language: en

## Inspect the actual manual interface

The [XTTS documentation](https://docs.coqui.ai/en/latest/models/xtts.html) exposes both `gpt_cond_latent` and `speaker_embedding` as outputs of reference conditioning and inputs to synthesis. It explicitly permits caching them for repeated use. This pair is a concrete interface contract. A service that stores only a field called voice embedding can accidentally discard one required component while still retaining a plausible tensor and a recognizable speaker label in its database.

## Locate the separate consumers

The [official model implementation](https://raw.githubusercontent.com/coqui-ai/TTS/dev/TTS/tts/models/xtts.py) passes GPT conditioning into the autoregressive path and the speaker embedding into the waveform decoder. Their roles are therefore distinct, not duplicate names for a shared object. Replacing one with the other based on shape manipulation does not preserve the trained computation. Keep their named identities when serializing, transferring between workers, or building a cache that serves repeated synthesis requests.

## Preserve reference-set preparation

The source prepares reference recordings before computing the conditioning objects, and its multiple-reference route combines information differently for the respective outputs. Record the actual selected recordings and preprocessing settings with the result. A voice name alone cannot identify that evidence. The [official release card](https://huggingface.co/coqui/XTTS-v2) anchors the selected model artifact; do not assume a cached pair remains compatible after replacing the checkpoint or importing artifacts produced by a different voice-generation system.

## Diagnose partial cache invalidation

Consider updating a noisy reference recording while reusing a previously stored speaker embedding. If only the GPT-side condition is recomputed, the result mixes artifacts from different preparation runs. Compare the complete regenerated pair against the mixed pair before changing text sampling controls. This diagnostic follows from the separate consumers; it does not claim that every mixed pair necessarily fails audibly or that one similarity score can prove the consistency of both conditioning objects.

## Version the conditioning bundle

Store model revision, reference identities, preparation configuration, both named tensors, and their format metadata together. Guides to [audio conditioning representations](/journal/audio-codec-token-generation/) and [artifact validation](/journal/safetensors-artifact-validation/) explain adjacent practices. Keep language and utterance settings in each synthesis request rather than treating them as part of an opaque voice name. A reproducible XTTS result needs a complete compatible conditioning bundle plus the effective generation configuration, beyond merely loading a familiar speaker vector onto the GPU.
