code: def gst_buffer_to_numpy_array(buf, chan):
      """Gst.Buffer to numpy array conversion"""
      assert buf.n_memory() == 1
      mem = buf.peek_memory(0)
      ret, info = mem.map(Gst.MapFlags.READ)
      if not ret:
          raise IOError
      samples = frombuffer(info.data, dtype="float32").reshape(
          (-1, chan)
      )
      mem.unmap(info)
      return samples
  
file_path: TimeSide/timeside/core/tools/gstutils.py
imports: from numpy import frombuffer
  import gi
  from gi.repository import GLib, GObject, Gst
  import threading
label_desc: Use image node_id 2 for calling a global function with example usage: gst_buffer_to_numpy_array(buf, chan) and returns: samples