class_docstr: ⓍTTS model implementation.
  
  ❗ Currently it only supports inference.
  
  Examples:
      >>> from TTS.tts.configs.xtts_config import XttsConfig
      >>> from TTS.tts.models.xtts import Xtts
      >>> config = XttsConfig()
      >>> model = Xtts.inif_from_config(config)
      >>> model.load_checkpoint(config, checkpoint_dir="paths/to/models_dir/", eval=True)
class_docstr_tok: ["\u24cdTTS","model","implementation",".","\u2757","Currently","it","only","supports","inference",".","Examples",":",">",">",">","from","TTS.tts.configs.xtts_config","import","XttsConfig",">",">",">","from","TTS.tts.models.xtts","import","Xtts",">",">",">","config","=","XttsConfig","(",")",">",">",">","model","=","Xtts.inif_from_config","(","config",")",">",">",">","model.load_checkpoint","(","config",",","checkpoint_dir=","''","paths\/to\/models_dir\/","''",",","eval=True",")"]
docstr: Compute the conditioning latents for the GPT model from the given audio.
  
  Args:
      audio (tensor): audio tensor.
      sr (int): Sample rate of the audio.
      length (int): Length of the audio in seconds. If < 0, use the whole audio. Defaults to 30.
      chunk_length (int): Length of the audio chunks in seconds. When `length == chunk_length`, the whole audio
          is being used without chunking. It must be < `length`. Defaults to 6.
docstr_tok: ["Compute","the","conditioning","latents","for","the","GPT","model","from","the","given","audio",".","Args",":","audio","(","tensor",")",":","audio","tensor",".","sr","(","int",")",":","Sample","rate","of","the","audio",".","length","(","int",")",":","Length","of","the","audio","in","seconds",".","If","<","0",",","use","the","whole","audio",".","Defaults","to","30.","chunk_length","(","int",")",":","Length","of","the","audio","chunks","in","seconds",".","When","`","length","==","chunk_length","`",",","the","whole","audio","is","being","used","without","chunking",".","It","must","be","<","`","length","`",".","Defaults","to","6","."]
code: def get_gpt_cond_latents(
      self, audio, sr, length: int = 30, chunk_length: int = 6
  ):
      """Compute the conditioning latents for the GPT model from the given audio.
  
      Args:
          audio (tensor): audio tensor.
          sr (int): Sample rate of the audio.
          length (int): Length of the audio in seconds. If < 0, use the whole audio. Defaults to 30.
          chunk_length (int): Length of the audio chunks in seconds. When `length == chunk_length`, the whole audio
              is being used without chunking. It must be < `length`. Defaults to 6.
      """
      if sr != 22050:
          audio = torchaudio.functional.resample(audio, sr, 22050)
      if length > 0:
          audio = audio[:, : 22050 * length]
      if self.args.gpt_use_perceiver_resampler:
          style_embs = []
          for i in range(0, audio.shape[1], 22050 * chunk_length):
              audio_chunk = audio[:, i : i + 22050 * chunk_length]
  
              # if the chunk is too short ignore it
              if audio_chunk.size(-1) < 22050 * 0.33:
                  continue
  
              mel_chunk = wav_to_mel_cloning(
                  audio_chunk,
                  mel_norms=self.mel_stats.cpu(),
                  n_fft=2048,
                  hop_length=256,
                  win_length=1024,
                  power=2,
                  normalized=False,
                  sample_rate=22050,
                  f_min=0,
                  f_max=8000,
                  n_mels=80,
              )
              style_emb = self.gpt.get_style_emb(
                  mel_chunk.to(self.device), None
              )
              style_embs.append(style_emb)
  
          # mean style embedding
          cond_latent = torch.stack(style_embs).mean(dim=0)
      else:
          mel = wav_to_mel_cloning(
              audio,
              mel_norms=self.mel_stats.cpu(),
              n_fft=4096,
              hop_length=1024,
              win_length=4096,
              power=2,
              normalized=False,
              sample_rate=22050,
              f_min=0,
              f_max=8000,
              n_mels=80,
          )
          cond_latent = self.gpt.get_style_emb(mel.to(self.device))
      return cond_latent.transpose(1, 2)
  
imports: import os
  from dataclasses import dataclass
  import librosa
  import torch
  import torch.nn.functional
  import torchaudio
  from coqpit import Coqpit
  from TTS.tts.layers.xtts.gpt import GPT
  from TTS.tts.layers.xtts.hifigan_decoder import HifiDecoder
  from TTS.tts.layers.xtts.stream_generator import init_stream_support
  from TTS.tts.layers.xtts.tokenizer import VoiceBpeTokenizer, split_sentence
  from TTS.tts.layers.xtts.xtts_manager import SpeakerManager, LanguageManager
  from TTS.tts.models.base_tts import BaseTTS
  from TTS.utils.io import load_fsspec
label_desc: Use image node_id 4 for calling the Xtts obj's underlying member method code with example usage: obj.get_gpt_cond_latents(audio, sr, length, chunk_length) and returns: cond_latent