code: def on_close(evt):
      print("Closing")
      # calculate average frame rate
      frame_rate = count[0] / (time.time() - start_time)
  
      # Close the stream and terminate pyAudio
      stream.stop_stream()
      stream.close()
      p.terminate()
      print("stream stopped")
      print("average frame rate = {:.0f} FPS".format(frame_rate))
      quit()
  
file_path: audio-spectrum-analyzer/spec_anim.py
imports: import matplotlib
  import pyaudio
  import os
  import struct
  import numpy
  import matplotlib.pyplot
  from matplotlib import animation
  from scipy.fftpack import fft
  import time
  from tkinter import TclError
label_desc: Use image node_id 1 for calling a global function with example usage: on_close(evt) without return types