def mu_law_encode(audio, quantization_channels):
 with tf.name_scope('encode'):
  mu = (quantization_channels - 1)
  magnitude = (tf.log((1 + (mu * tf.abs(audio)))) / tf.log((1.0 + mu)))
  signal = (tf.sign(audio) * magnitude)
  return tf.cast(((((signal + 1) / 2) * mu) + 0.5), tf.int32)

def mu_law_encode ( audio , quantization_channels ) : with tf . name_scope ( 'encode' ) : mu = ( quantization_channels - 1 ) magnitude = ( tf . log ( ( 1 + ( mu * tf . abs ( audio ) ) ) ) / tf . log ( ( 1.0 + mu ) ) ) signal = ( tf . sign ( audio ) * magnitude ) return tf . cast ( ( ( ( ( signal + 1 ) / 2 ) * mu ) + 0.5 ) , tf . int32 )
quantizes waveform amplitudes .