code: def _array2wav(a, sampwidth):
      """
      Convert the input array `a` to a string of WAV data.
      a.dtype must be one of uint8, int16 or int32.  Allowed sampwidth
      values are:
          dtype    sampwidth
          uint8        1
          int16        2
          int32      3 or 4
      When sampwidth is 3, the *low* bytes of `a` are assumed to contain
      the values to include in the string.
      """
      if sampwidth == 3:
          # `a` must have dtype int32
          if a.ndim == 1:
              # Convert to a 2D array with a single column.
              a = a.reshape(-1, 1)
          # By shifting first 0 bits, then 8, then 16, the resulting output
          # is 24 bit little-endian.
          a8 = (
              a.reshape(a.shape + (1,)) >> _np.array([0, 8, 16])
          ) & 255
          wavdata = a8.astype(_np.uint8).tostring()
      else:
          # Make sure the array is little-endian, and then convert using
          # tostring()
          a = a.astype("<" + a.dtype.str[1:], copy=False)
          wavdata = a.tostring()
      return wavdata
  
file_path: dejavu/dejavu/third_party/wavio.py
imports: import wave
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: _array2wav(a, sampwidth) and returns: wavdata