code: def gen_audio_file(
      path,
      sample_rate,
      num_channels,
      *,
      encoding=None,
      bit_depth=None,
      compression=None,
      attenuation=None,
      duration=1,
      comment_file=None,
  ):
      """Generate synthetic audio file with `sox` command."""
      if path.endswith(".wav"):
          warnings.warn(
              "Use get_wav_data and save_wav to generate wav file for accurate result."
          )
      command = [
          "sox",
          "-V3",  # verbose
          "--no-dither",  # disable automatic dithering
          "-R",
          # -R is supposed to be repeatable, though the implementation looks suspicious
          # and not setting the seed to a fixed value.
          # https://fossies.org/dox/sox-14.4.2/sox_8c_source.html
          # search "sox_globals.repeatable"
      ]
      if bit_depth is not None:
          command += ["--bits", str(bit_depth)]
      command += [
          "--rate",
          str(sample_rate),
          "--null",  # no input
          "--channels",
          str(num_channels),
      ]
      if compression is not None:
          command += ["--compression", str(compression)]
      if bit_depth is not None:
          command += ["--bits", str(bit_depth)]
      if encoding is not None:
          command += ["--encoding", str(encoding)]
      if comment_file is not None:
          command += ["--comment-file", str(comment_file)]
      command += [
          str(path),
          "synth",
          str(duration),  # synthesizes for the given duration [sec]
          "sawtooth",
          "1",
          # saw tooth covers the both ends of value range, which is a good property for test.
          # similar to linspace(-1., 1.)
          # this introduces bigger boundary effect than sine when converted to mp3
      ]
      if attenuation is not None:
          command += ["vol", f"-{attenuation}dB"]
      print(" ".join(command), file=sys.stderr)
      subprocess.run(command, check=True)
  
file_path: audio/test/torchaudio_unittest/common_utils/sox_utils.py
imports: import subprocess
  import sys
  import warnings
label_desc: Use image node_id 3 for calling a global function with example usage: gen_audio_file(path, sample_rate, num_channels) without return types