code: def test_full_generate_speech():
      os.environ["CUDA_HOME"] = "/usr/local/cuda-11.7"
      from src.tts_coqui import (
          generate_speech,
          get_xtt,
          get_latent,
          get_role_to_wave_map,
      )
  
      bot = "I am an AI assistant.  What do you want from me?  I am very busy."
  
      def response_gen():
          for word1 in bot.split(" "):
              yield word1
  
      chatbot_role = "Female AI Assistant"
      model, supported_languages = get_xtt()
      latent = get_latent(
          get_role_to_wave_map()[chatbot_role], model=model
      )
  
      response = ""
      sentence_state = init_sentence_state()
  
      sentences = []
      audios = []
      sentences_expected = [
          "I am an AI assistant.",
          "What do you want from me?",
          "I am very busy.",
      ]
      for word in response_gen():
          response += word + " "
          audio, sentence, sentence_state = generate_speech(
              response,
              model=model,
              supported_languages=supported_languages,
              latent=latent,
              sentence_state=sentence_state,
              return_as_byte=False,
              return_nonbyte_as_file=True,
              return_gradio=False,
              is_final=False,
              verbose=True,
          )
          if sentence is not None:
              print(sentence)
              sentences.append(sentence)
          if audio is not None:
              audios.append(audio)
      audio, sentence, sentence_state = generate_speech(
          response,
          model=model,
          supported_languages=supported_languages,
          latent=latent,
          sentence_state=sentence_state,
          return_as_byte=False,
          return_nonbyte_as_file=True,
          return_gradio=False,
          is_final=True,
          verbose=True,
      )
      if sentence is not None:
          print(sentence)
          sentences.append(sentence)
      if audio is not None:
          audios.append(audio)
      assert sentences == sentences_expected
      assert len(sentences) == len(audios)
      print(audios)
  
file_path: h2ogpt/tests/test_tts.py
imports: import os
  import pytest
  from tests.utils import wrap_test_forked
  from src.tts_sentence_parsing import init_sentence_state
  from tests.test_sentence_parsing import bot_list
label_desc: Use image node_id 3 for calling a global function with example usage: test_full_generate_speech() without return types