code: def get_file_info(infile, cmd="ffprobe"):
      """
      Extract and return information about audio files.
  
      Parameters
      ----------
      infile : str
          Name of the audio file.
      cmd : {'ffprobe', 'avprobe'}, optional
          Probing command (defaults to ffprobe, alternatively supports avprobe).
  
      Returns
      -------
      dict
          Audio file information.
  
      """
      # init dictionary
      info = {"num_channels": None, "sample_rate": None}
      if isinstance(infile, Signal):
          info["num_channels"] = infile.num_channels
          info["sample_rate"] = infile.sample_rate
      else:
          # call ffprobe
          if isinstance(infile, file_types):
              call = [cmd, "-v", "quiet", "-show_streams", "pipe:0"]
              proc = subprocess.Popen(
                  call, stdin=subprocess.PIPE, stdout=subprocess.PIPE
              )
              output, _ = proc.communicate(infile.read())
              retcode = proc.poll()
              infile.seek(0)
              if retcode:
                  raise subprocess.CalledProcessError(
                      retcode, call, output=output
                  )
          else:
              output = subprocess.check_output(
                  [cmd, "-v", "quiet", "-show_streams", infile]
              )
          # parse information
          for line in output.split():
              if line.startswith(b"channels="):
                  info["num_channels"] = int(line[len("channels=") :])
              if line.startswith(b"sample_rate="):
                  # the int(float(...)) conversion is necessary because
                  # avprobe returns sample_rate as floating point number
                  # which int() can't handle.
                  info["sample_rate"] = int(
                      float(line[len("sample_rate=") :])
                  )
      # return the dictionary
      return info
  
imports: from __future__ import absolute_import, division, print_function
  import errno
  import os
  import subprocess
  import sys
  import tempfile
  import numpy
  from ..audio.signal import Signal
  from ..utils import string_types, file_types
label_desc: Use image node_id 7 for calling a global function with example usage: get_file_info(infile, cmd) and returns: info