code: def encoderTest(self, filename, bitrate=320, precision=1e-7):
      from math import sin, pi
  
      format = os.path.splitext(filename)[1].split(".")[1]
      sr = 44100
      sine = [
          i / 44100.0 * sin(2.0 * pi * 10.0 * i / sr) for i in range(sr)
      ]
      # sine = [0.5*sin(2.0*pi*10.0*i/sr) for i in xrange(sr)]
      signal = array([[val, val] for val in sine])
  
      # write the audio file:
      gen = VectorInput(signal)
      writer = AudioWriter(
          filename=filename, format=format, bitrate=bitrate
      )
      gen.data >> writer.audio
      run(gen)
  
      # load the audio file and validate:
      loader = AudioLoader(filename=filename)
      mixer = MonoMixer(type="left")
      pool = Pool()
      loader.audio >> mixer.audio
      mixer.audio >> (pool, "audio")
      loader.numberChannels >> mixer.numberChannels
      loader.sampleRate >> None
      loader.md5 >> None
      loader.bit_rate >> None
      loader.codec >> None
      run(loader)
  
      from essentia.standard import ZeroCrossingRate
  
      zcr = int(
          ZeroCrossingRate(threshold=0.001)(pool["audio"])
          * len(pool["audio"])
          + 0.5
      )
      expected = int(
          ZeroCrossingRate(threshold=0.0)(sine) * len(sine) + 0.5
      )
      # for debugging:
      # from pylab import show, plot, figure
      # from essentia.standard import MonoLoader
      # plot(sine)
      # plot(MonoLoader(filename=filename)())
      # show(figure)
  
      os.remove(filename)
  
      self.assertAlmostEqual(max(pool["audio"]), max(sine), precision)
      self.assertEqual(zcr, expected)
  
file_path: essentia/test/src/unittests/io/test_audiowriter_streaming.py
imports: from essentia_test import *
  from essentia.streaming import AudioWriter, AudioLoader
  from essentia.streaming import MonoMixer
  import os
label_desc: Use image node_id 6 for calling the TestAudioWriter_Streaming obj's underlying member method code with example usage: obj.encoderTest(filename, bitrate, precision) without return types