class_docstr: Saves data in event and summary protos for tensorboard.
class_docstr_tok: ["Saves","data","in","event","and","summary","protos","for","tensorboard","."]
docstr: Saves audio.
  
  NB: single channel only right now.
  
  Args:
    tag: str: label for this data
    audiodata: ndarray [Nsamples,]: data between (-1.0,1.0) to save as wave
    step: int: training step
    sample_rate: sample rate of passed in audio buffer
docstr_tok: ["Saves","audio",".","NB",":","single","channel","only","right","now",".","Args",":","tag",":","str",":","label","for","this","data","audiodata",":","ndarray","[","Nsamples",",","]",":","data","between","(","-1.0,1.0",")","to","save","as","wave","step",":","int",":","training","step","sample_rate",":","sample","rate","of","passed","in","audio","buffer"]
code: def audio(self, tag, audiodata, step=None, sample_rate=44100):
      """Saves audio.
  
      NB: single channel only right now.
  
      Args:
        tag: str: label for this data
        audiodata: ndarray [Nsamples,]: data between (-1.0,1.0) to save as wave
        step: int: training step
        sample_rate: sample rate of passed in audio buffer
      """
      audiodata = np.array(audiodata)
      if step is None:
          step = self._step
      else:
          self._step = step
      audiodata = np.clip(np.squeeze(audiodata), -1, 1)
      if audiodata.ndim != 1:
          raise ValueError("Audio data must be 1D.")
      sample_list = (32767.0 * audiodata).astype(int).tolist()
      wio = io.BytesIO()
      wav_buf = wave.open(wio, "wb")
      wav_buf.setnchannels(1)
      wav_buf.setsampwidth(2)
      wav_buf.setframerate(sample_rate)
      enc = b"".join([struct.pack("<h", v) for v in sample_list])
      wav_buf.writeframes(enc)
      wav_buf.close()
      encoded_audio_bytes = wio.getvalue()
      wio.close()
      audio = tf.compat.v1.Summary.Audio(
          sample_rate=sample_rate,
          num_channels=1,
          length_frames=len(sample_list),
          encoded_audio_string=encoded_audio_bytes,
          content_type="audio/wav",
      )
      summary = tf.compat.v1.Summary(
          value=[tf.compat.v1.Summary.Value(tag=tag, audio=audio)]
      )
      self.add_summary(summary, step)
  
imports: import io
  import struct
  import time
  import warnings
  import wave
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import tensorflow
  from tensorflow.core.util import event_pb2
  from tensorflow.python.summary.writer.event_file_writer import EventFileWriter
label_desc: Use image node_id 10 for calling the SummaryWriter obj's underlying member method code with example usage: obj.audio(tag, audiodata, step, sample_rate) without return types