(waves, length, channels)
return waves
Crop or pad wave to have shape [N, length, channels].

  Args:
    waves: A 3D `Tensor` of NLC format.
    length: A Python scalar. The output wave size.
    channels: Number of output waves channels.

  Returns:
    A 3D `Tensor` of NLC format with shape [N, length, channels].
Crop or pad wave to have shape [N, length, channels].
Crop or pad wave to have shape [ N length channels ] .
def crop_or_pad(waves, length, channels):
  """Crop or pad wave to have shape [N, length, channels].

  Args:
    waves: A 3D `Tensor` of NLC format.
    length: A Python scalar. The output wave size.
    channels: Number of output waves channels.

  Returns:
    A 3D `Tensor` of NLC format with shape [N, length, channels].
  """
  waves = tf.convert_to_tensor(waves)
  batch_size = int(waves.shape[0])
  waves_shape = tf.shape(waves)

  # Force audio length.
  pad = tf.maximum(0, length - waves_shape[1])
  right_pad = tf.to_int32(tf.to_float(pad) / 2.0)
  left_pad = pad - right_pad
  waves = tf.pad(waves, [[0, 0], [left_pad, right_pad], [0, 0]])
  waves = waves[:, :length, :]

  # Force number of channels.
  num_repeats = tf.to_int32(
      tf.ceil(tf.to_float(channels) / tf.to_float(waves_shape[2])))
  waves = tf.tile(waves, [1, 1, num_repeats])[:, :, :channels]

  waves.set_shape([batch_size, length, channels])
  return waves
def crop_or_pad ( waves , length , channels ) : waves = tf . convert_to_tensor ( waves ) batch_size = int ( waves . shape [ 0 ] ) waves_shape = tf . shape ( waves ) # Force audio length. pad = tf . maximum ( 0 , length - waves_shape [ 1 ] ) right_pad = tf . to_int32 ( tf . to_float ( pad ) / 2.0 ) left_pad = pad - right_pad waves = tf . pad ( waves , [ [ 0 , 0 ] , [ left_pad , right_pad ] , [ 0 , 0 ] ] ) waves = waves [ : , : length , : ] # Force number of channels. num_repeats = tf . to_int32 ( tf . ceil ( tf . to_float ( channels ) / tf . to_float ( waves_shape [ 2 ] ) ) ) waves = tf . tile ( waves , [ 1 , 1 , num_repeats ] ) [ : , : , : channels ] waves . set_shape ( [ batch_size , length , channels ] ) return waves