code: def generate_speech(
      response,
      model=None,
      language="autodetect",
      supported_languages=None,
      latent=None,
      sentence_state=None,
      return_as_byte=True,
      return_nonbyte_as_file=False,
      sr=24000,
      tts_speed=1.0,
      return_gradio=False,
      is_final=False,
      verbose=False,
      debug=False,
  ):
      if model is None or supported_languages is None:
          model, supported_languages = get_xtt()
      if sentence_state is None:
          sentence_state = init_sentence_state()
      if latent is None:
          latent = get_latent("models/female.wav", model=model)
  
      sentence, sentence_state, _ = get_sentence(
          response,
          sentence_state=sentence_state,
          is_final=is_final,
          verbose=verbose,
      )
      if sentence:
          t0 = time.time()
          if verbose:
              print("sentence_to_wave: %s" % sentence)
  
          audio = sentence_to_wave(
              sentence,
              supported_languages,
              tts_speed,
              model=model,
              latent=latent,
              return_as_byte=return_as_byte,
              return_nonbyte_as_file=return_nonbyte_as_file,
              sr=sr,
              language=language,
              return_gradio=return_gradio,
          )
          if verbose:
              print(
                  "done sentence_to_wave: %s" % (time.time() - t0),
                  flush=True,
              )
      else:
          if verbose and debug:  # too much in general
              print("No audio", flush=True)
          no_audio = get_no_audio(
              sr=sr,
              return_as_byte=return_as_byte,
              return_nonbyte_as_file=return_nonbyte_as_file,
          )
          if return_gradio:
              import gradio as gr
  
              audio = gr.Audio(value=no_audio, autoplay=False)
          else:
              audio = no_audio
      return audio, sentence, sentence_state
  
imports: from __future__ import annotations
  import functools
  import io
  import os
  import tempfile
  import numpy
  import uuid
  import subprocess
  import time
  from src.tts_sentence_parsing import init_sentence_state, get_sentence, clean_sentence, detect_language
  from src.tts_utils import prepare_speech, get_no_audio, chunk_speed_change
  from src.utils import cuda_vis_check
  import torch
label_desc: Use image node_id 5 for calling a global function with example usage: generate_speech(response, model, language, supported_languages, latent, sentence_state, return_as_byte, return_nonbyte_as_file, sr, tts_speed, return_gradio, is_final, verbose, debug) and returns: audio,  sentence,  sentence_state