code: def play(
      array_of_floats,
      sample_rate=DEFAULT_SAMPLE_RATE,
      ephemeral=True,
      autoplay=False,
  ):
      """Creates an HTML5 audio widget to play a sound in Colab.
  
      This function should only be called from a Colab notebook.
  
      Args:
        array_of_floats: A 1D or 2D array-like container of float sound samples.
          Values outside of the range [-1, 1] will be clipped.
        sample_rate: Sample rate in samples per second.
        ephemeral: If set to True, the widget will be ephemeral, and disappear on
          reload (and it won't be counted against realtime document size).
        autoplay: If True, automatically start playing the sound when the widget is
          rendered.
      """
      # If batched, take first element.
      if len(array_of_floats.shape) == 2:
          array_of_floats = array_of_floats[0]
  
      normalizer = float(np.iinfo(np.int16).max)
      array_of_ints = np.array(
          np.asarray(array_of_floats) * normalizer, dtype=np.int16
      )
      memfile = io.BytesIO()
      wavfile.write(memfile, sample_rate, array_of_ints)
      html = """<audio controls {autoplay}>
                <source controls src="data:audio/wav;base64,{base64_wavfile}"
                type="audio/wav" />
                Your browser does not support the audio element.
              </audio>"""
      html = html.format(
          autoplay="autoplay" if autoplay else "",
          base64_wavfile=base64.b64encode(memfile.getvalue()).decode(
              "ascii"
          ),
      )
      memfile.close()
      global _play_count
      _play_count += 1
      if ephemeral:
          element = "id_%s" % _play_count
          display.display(
              display.HTML('<div id="%s"> </div>' % element)
          )
          js = output._js_builder  # pylint:disable=protected-access
          js.Js("document", mode=js.EVAL).getElementById(
              element
          ).innerHTML = html
      else:
          display.display(display.HTML(html))
  
file_path: ddsp/ddsp/colab/colab_utils.py
imports: import base64
  import io
  import pickle
  import ddsp
  import ddsp.training
  from google.colab import files
  from google.colab import output
  from IPython import display
  import note_seq
  import numpy
  from scipy.io import wavfile
  import tensorflow.compat.v2
label_desc: Use image node_id 1 for calling a global function with example usage: play(array_of_floats, sample_rate, ephemeral, autoplay) without return types