code: def _wav2array(nchannels, sampwidth, data):
      """data must be the string containing the bytes from the wav file."""
      num_samples, remainder = divmod(len(data), sampwidth * nchannels)
      if remainder > 0:
          raise ValueError(
              "The length of data is not a multiple of "
              "sampwidth * num_channels."
          )
      if sampwidth > 4:
          raise ValueError("sampwidth must not be greater than 4.")
  
      if sampwidth == 3:
          a = _np.empty((num_samples, nchannels, 4), dtype=_np.uint8)
          raw_bytes = _np.frombuffer(data, dtype=_np.uint8)
          a[:, :, :sampwidth] = raw_bytes.reshape(
              -1, nchannels, sampwidth
          )
          a[:, :, sampwidth:] = (
              a[:, :, sampwidth - 1 : sampwidth] >> 7
          ) * 255
          result = a.view("<i4").reshape(a.shape[:-1])
      else:
          # 8 bit samples are stored as unsigned ints; others as signed ints.
          dt_char = "u" if sampwidth == 1 else "i"
          a = _np.frombuffer(data, dtype=f"<{dt_char}{sampwidth}")
          result = a.reshape(-1, nchannels)
      return result
  
file_path: dejavu/dejavu/third_party/wavio.py
imports: import wave
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _wav2array(nchannels, sampwidth, data) and returns: result