class_docstr: Tortoise model class.
  
  Currently only supports inference.
  
  Examples:
      >>> from TTS.tts.configs.tortoise_config import TortoiseConfig
      >>> from TTS.tts.models.tortoise import Tortoise
      >>> config = TortoiseConfig()
      >>> model = Tortoise.inif_from_config(config)
      >>> model.load_checkpoint(config, checkpoint_dir="paths/to/models_dir/", eval=True)
class_docstr_tok: ["Tortoise","model","class",".","Currently","only","supports","inference",".","Examples",":",">",">",">","from","TTS.tts.configs.tortoise_config","import","TortoiseConfig",">",">",">","from","TTS.tts.models.tortoise","import","Tortoise",">",">",">","config","=","TortoiseConfig","(",")",">",">",">","model","=","Tortoise.inif_from_config","(","config",")",">",">",">","model.load_checkpoint","(","config",",","checkpoint_dir=","''","paths\/to\/models_dir\/","''",",","eval=True",")"]
docstr: Synthesize speech with the given input text.
  
  Args:
      text (str): Input text.
      config (TortoiseConfig): Config with inference parameters.
      speaker_id (str): One of the available speaker names. If `random`, it generates a random speaker.
      voice_dirs (List[str]): List of paths that host reference audio files for speakers. Defaults to None.
      **kwargs: Inference settings. See `inference()`.
  
  Returns:
      A dictionary of the output values with `wav` as output waveform, `deterministic_seed` as seed used at inference,
      `text_input` as text token IDs after tokenizer, `voice_samples` as samples used for cloning, `conditioning_latents`
      as latents used at inference.
docstr_tok: ["Synthesize","speech","with","the","given","input","text",".","Args",":","text","(","str",")",":","Input","text",".","config","(","TortoiseConfig",")",":","Config","with","inference","parameters",".","speaker_id","(","str",")",":","One","of","the","available","speaker","names",".","If","`","random","`",",","it","generates","a","random","speaker",".","voice_dirs","(","List","[","str","]",")",":","List","of","paths","that","host","reference","audio","files","for","speakers",".","Defaults","to","None",".","*","*","kwargs",":","Inference","settings",".","See","`","inference","(",")","`",".","Returns",":","A","dictionary","of","the","output","values","with","`","wav","`","as","output","waveform",",","`","deterministic_seed","`","as","seed","used","at","inference",",","`","text_input","`","as","text","token","IDs","after","tokenizer",",","`","voice_samples","`","as","samples","used","for","cloning",",","`","conditioning_latents","`","as","latents","used","at","inference","."]
code: def synthesize(
      self, text, config, speaker_id="random", voice_dirs=None, **kwargs
  ):
      """Synthesize speech with the given input text.
  
      Args:
          text (str): Input text.
          config (TortoiseConfig): Config with inference parameters.
          speaker_id (str): One of the available speaker names. If `random`, it generates a random speaker.
          voice_dirs (List[str]): List of paths that host reference audio files for speakers. Defaults to None.
          **kwargs: Inference settings. See `inference()`.
  
      Returns:
          A dictionary of the output values with `wav` as output waveform, `deterministic_seed` as seed used at inference,
          `text_input` as text token IDs after tokenizer, `voice_samples` as samples used for cloning, `conditioning_latents`
          as latents used at inference.
  
      """
  
      speaker_id = "random" if speaker_id is None else speaker_id
  
      if voice_dirs is not None:
          voice_dirs = [voice_dirs]
          voice_samples, conditioning_latents = load_voice(
              speaker_id, voice_dirs
          )
  
      else:
          voice_samples, conditioning_latents = load_voice(speaker_id)
  
      outputs = self.inference_with_config(
          text,
          config,
          voice_samples=voice_samples,
          conditioning_latents=conditioning_latents,
          **kwargs,
      )
  
      return_dict = {
          "wav": outputs["wav"],
          "deterministic_seed": outputs["deterministic_seed"],
          "text_inputs": outputs["text"],
          "voice_samples": outputs["voice_samples"],
          "conditioning_latents": outputs["conditioning_latents"],
      }
  
      return return_dict
  
imports: import os
  import random
  from contextlib import contextmanager
  from dataclasses import dataclass
  from time import time
  import torch
  import torch.nn.functional
  import torchaudio
  from coqpit import Coqpit
  from tqdm import tqdm
  from TTS.tts.layers.tortoise.arch_utils import TorchMelSpectrogram
  from TTS.tts.layers.tortoise.audio_utils import denormalize_tacotron_mel, load_voice, wav_to_univnet_mel
  from TTS.tts.layers.tortoise.autoregressive import UnifiedVoice
  from TTS.tts.layers.tortoise.classifier import AudioMiniEncoderWithClassifierHead
  from TTS.tts.layers.tortoise.clvp import CLVP
  from TTS.tts.layers.tortoise.diffusion import SpacedDiffusion, get_named_beta_schedule, space_timesteps
  from TTS.tts.layers.tortoise.diffusion_decoder import DiffusionTts
  from TTS.tts.layers.tortoise.random_latent_generator import RandomLatentConverter
  from TTS.tts.layers.tortoise.tokenizer import VoiceBpeTokenizer
  from TTS.tts.layers.tortoise.vocoder import VocConf, VocType
  from TTS.tts.layers.tortoise.wav2vec_alignment import Wav2VecAlignment
  from TTS.tts.models.base_tts import BaseTTS
label_desc: Use image node_id 5 for calling the Tortoise obj's underlying member method code with example usage: obj.synthesize(text, config, speaker_id, voice_dirs) and returns: return_dict