class_docstr: Helper functions to compute specgrams.
class_docstr_tok: ["Helper","functions","to","compute","specgrams","."]
docstr: Converts specgrams to melspecgrams.
  
  Args:
    specgrams: Tensor of log magnitudes and instantaneous frequencies,
      shape [batch, time, freq, 2].
  
  Returns:
    melspecgrams: Tensor of log magnitudes and instantaneous frequencies,
      shape [batch, time, freq, 2], mel scaling of frequencies.
docstr_tok: ["Converts","specgrams","to","melspecgrams",".","Args",":","specgrams",":","Tensor","of","log","magnitudes","and","instantaneous","frequencies",",","shape","[","batch",",","time",",","freq",",","2","]",".","Returns",":","melspecgrams",":","Tensor","of","log","magnitudes","and","instantaneous","frequencies",",","shape","[","batch",",","time",",","freq",",","2","]",",","mel","scaling","of","frequencies","."]
code: def specgrams_to_melspecgrams(self, specgrams):
      """Converts specgrams to melspecgrams.
  
      Args:
        specgrams: Tensor of log magnitudes and instantaneous frequencies,
          shape [batch, time, freq, 2].
  
      Returns:
        melspecgrams: Tensor of log magnitudes and instantaneous frequencies,
          shape [batch, time, freq, 2], mel scaling of frequencies.
      """
      if self._mel_downscale is None:
          return specgrams
  
      logmag = specgrams[:, :, :, 0]
      p = specgrams[:, :, :, 1]
  
      mag2 = tf.exp(2.0 * logmag)
      phase_angle = tf.cumsum(p * np.pi, axis=-2)
  
      l2mel = tf.to_float(self._linear_to_mel_matrix())
      logmelmag2 = self._safe_log(tf.tensordot(mag2, l2mel, 1))
      mel_phase_angle = tf.tensordot(phase_angle, l2mel, 1)
      mel_p = spectral_ops.instantaneous_frequency(mel_phase_angle)
  
      return tf.concat(
          [logmelmag2[:, :, :, tf.newaxis], mel_p[:, :, :, tf.newaxis]],
          axis=-1,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from magenta.models.gansynth.lib import spectral_ops
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 11 for calling the SpecgramsHelper obj's underlying member method code with example usage: obj.specgrams_to_melspecgrams(specgrams) and returns: tf, specgrams