code: def combine_audios(
      audios,
      audio=None,
      channels=1,
      sample_width=2,
      sr=24000,
      expect_bytes=True,
  ):
      no_audio = get_no_audio(sr=sr)
      have_audio = any(
          x not in [no_audio, None, ""] for x in audios
      ) or audio not in [no_audio, None, ""]
      if not have_audio:
          return no_audio
  
      if audio or audios:
          is_bytes = expect_bytes  # force default as bytes no matter input if know should have been bytes
          if audios:
              is_bytes |= isinstance(audios[0], (bytes, bytearray))
          if audio:
              is_bytes |= isinstance(audio, (bytes, bytearray))
          assert audio is None or isinstance(audio, (bytes, bytearray))
          from pydub import AudioSegment
  
          combined_wav = AudioSegment.empty()
          for x in audios:
              if x is not None:
                  s = io.BytesIO(x) if is_bytes else x
                  combined_wav += AudioSegment.from_raw(
                      s,
                      sample_width=sample_width,
                      frame_rate=sr,
                      channels=channels,
                  )
          if audio is not None:
              s = io.BytesIO(audio) if is_bytes else audio
              combined_wav += AudioSegment.from_raw(
                  s,
                  sample_width=sample_width,
                  frame_rate=sr,
                  channels=channels,
              )
          if is_bytes:
              combined_wav = combined_wav.export(format="raw").read()
          return combined_wav
      # audio just empty stream, but not None, else would nuke audio
      return audio
  
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 4 for calling a global function with example usage: combine_audios(audios, audio, channels, sample_width, sr, expect_bytes) and returns: audio, no_audio, combined_wav