code: def chunk_speed_change(chunk, sr, tts_speed=1.0):
      if tts_speed == 1.0:
          return chunk
  
      if have_pyrubberband:
          import pyrubberband as pyrb
  
          chunk = pyrb.time_stretch(chunk, sr, tts_speed)
          chunk = (chunk * 32767).astype(np.int16)
          return chunk
  
      if tts_speed < 1.0:
          # chunk = chunk.astype(np.float32)
          # chunk = 0.5 * chunk / np.max(chunk)
          # chunk = librosa.effects.time_stretch(chunk, rate=tts_speed)
          return chunk
  
      # speed-up
      from pydub import AudioSegment
      from pydub.effects import speedup
  
      s = io.BytesIO(chunk)
      channels = 1
      sample_width = 2
      audio = AudioSegment.from_raw(
          s, sample_width=sample_width, frame_rate=sr, channels=channels
      )
      # chunk = speedup(audio, tts_speed, 150).export(format='raw').read()
      chunk = pydub_to_np(speedup(audio, tts_speed, 150))
      # audio = audio._spawn(audio.raw_data, overrides={
      #    "frame_rate": int(audio.frame_rate * tts_speed)
      # })
      # chunk = np.array(audio.get_array_of_samples())
  
      return chunk
  
file_path: h2ogpt/src/tts_utils.py
imports: import io
  import librosa
  import numpy
  import pydub
  from src.utils import have_pyrubberband
label_desc: Use image node_id 5 for calling a global function with example usage: chunk_speed_change(chunk, sr, tts_speed) and returns: chunk, chunk, chunk, chunk