(spec,
                       name,
                       hparams,
                       rows=4,
                       columns=4,
                       image=True,
                       phase=True,
                       audio=True)
Post summaries of a specgram (Image and Audio).

  For image summaries, creates a rows x columns composite image from the batch.
  Also can create audio summaries for raw audio, but hparams.raw_audio must be
  True.
  Args:
    spec: Batch of spectrograms.
    name: String prepended to summaries.
    hparams: Hyperparamenters.
    rows: Int, number of rows in image.
    columns: Int, number of columns in image.
    image: Bool, create image summary.
    phase: Bool, create image summary from second channel in the batch.
    audio: Bool, create audio summaries for each spectrogram in the batch.
Post summaries of a specgram (Image and Audio).
Post summaries of a specgram ( Image and Audio ) .
def specgram_summaries(spec,
                       name,
                       hparams,
                       rows=4,
                       columns=4,
                       image=True,
                       phase=True,
                       audio=True):
  """Post summaries of a specgram (Image and Audio).

  For image summaries, creates a rows x columns composite image from the batch.
  Also can create audio summaries for raw audio, but hparams.raw_audio must be
  True.
  Args:
    spec: Batch of spectrograms.
    name: String prepended to summaries.
    hparams: Hyperparamenters.
    rows: Int, number of rows in image.
    columns: Int, number of columns in image.
    image: Bool, create image summary.
    phase: Bool, create image summary from second channel in the batch.
    audio: Bool, create audio summaries for each spectrogram in the batch.
  """
  batch_size, n_freq, n_time, unused_channels = spec.get_shape().as_list()
  # Must divide minibatch evenly
  b = min(batch_size, rows * columns)

  if hparams.raw_audio:
    spec = tf.squeeze(spec)
    spec /= tf.expand_dims(tf.reduce_max(spec, axis=1), axis=1)
    tf.summary.audio(
        name, tf.squeeze(spec), hparams.samples_per_second, max_outputs=b)
  else:
    if image:
      if b % columns != 0:
        rows = np.floor(np.sqrt(b))
        columns = rows
      else:
        rows = b / columns
      tf.summary.image("Mag/%s" % name,
                       form_image_grid(spec[:b, :, :, :1], [rows, columns],
                                       [n_freq, n_time], 1))
      if phase:
        tf.summary.image("Phase/%s" % name,
                         form_image_grid(spec[:b, :, :, 1:], [rows, columns],
                                         [n_freq, n_time], 1))
    if audio:
      tf.summary.audio(
          name,
          tf_ispecgram(
              spec,
              n_fft=hparams.n_fft,
              hop_length=hparams.hop_length,
              mask=hparams.mask,
              log_mag=hparams.log_mag,
              pad=hparams.pad,
              re_im=hparams.re_im,
              dphase=hparams.dphase,
              mag_only=hparams.mag_only),
          hparams.samples_per_second,
          max_outputs=b)
def specgram_summaries ( spec , name , hparams , rows = 4 , columns = 4 , image = True , phase = True , audio = True ) : batch_size , n_freq , n_time , unused_channels = spec . get_shape ( ) . as_list ( ) # Must divide minibatch evenly b = min ( batch_size , rows * columns ) if hparams . raw_audio : spec = tf . squeeze ( spec ) spec /= tf . expand_dims ( tf . reduce_max ( spec , axis = 1 ) , axis = 1 ) tf . summary . audio ( name , tf . squeeze ( spec ) , hparams . samples_per_second , max_outputs = b ) else : if image : if b % columns != 0 : rows = np . floor ( np . sqrt ( b ) ) columns = rows else : rows = b / columns tf . summary . image ( "Mag/%s" % name , form_image_grid ( spec [ : b , : , : , : 1 ] , [ rows , columns ] , [ n_freq , n_time ] , 1 ) ) if phase : tf . summary . image ( "Phase/%s" % name , form_image_grid ( spec [ : b , : , : , 1 : ] , [ rows , columns ] , [ n_freq , n_time ] , 1 ) ) if audio : tf . summary . audio ( name , tf_ispecgram ( spec , n_fft = hparams . n_fft , hop_length = hparams . hop_length , mask = hparams . mask , log_mag = hparams . log_mag , pad = hparams . pad , re_im = hparams . re_im , dphase = hparams . dphase , mag_only = hparams . mag_only ) , hparams . samples_per_second , max_outputs = b )