(example_proto, hparams, is_training)
Compute spectral representation, labels, and length from sequence/audio.

  Args:
    example_proto: Example that has not been preprocessed.
    hparams: HParams object specifying hyperparameters.
    is_training: Whether or not this is a training run.

  Returns:
    An InputTensors tuple.

  Raises:
    ValueError: If hparams is contains an invalid spec_type.
Compute spectral representation, labels, and length from sequence/audio.
Compute spectral representation labels and length from sequence / audio .
def preprocess_example(example_proto, hparams, is_training):
  """Compute spectral representation, labels, and length from sequence/audio.

  Args:
    example_proto: Example that has not been preprocessed.
    hparams: HParams object specifying hyperparameters.
    is_training: Whether or not this is a training run.

  Returns:
    An InputTensors tuple.

  Raises:
    ValueError: If hparams is contains an invalid spec_type.
  """
  record = parse_example(example_proto)
  sequence_id = record['id']
  sequence = record['sequence']
  audio = record['audio']
  velocity_range = record['velocity_range']

  wav_jitter_amount_ms = label_jitter_amount_ms = 0
  # if there is combined jitter, we must generate it once here
  if is_training and hparams.jitter_amount_ms > 0:
    wav_jitter_amount_ms = np.random.choice(hparams.jitter_amount_ms, size=1)
    label_jitter_amount_ms = wav_jitter_amount_ms

  if label_jitter_amount_ms > 0:
    sequence = jitter_label_op(sequence, label_jitter_amount_ms / 1000.)

  # possibly shift the entire sequence backward for better forward only training
  if hparams.backward_shift_amount_ms > 0:
    sequence = jitter_label_op(sequence,
                               hparams.backward_shift_amount_ms / 1000.)

  if is_training:
    audio = transform_wav_data_op(
        audio,
        hparams=hparams,
        jitter_amount_sec=wav_jitter_amount_ms / 1000.)

  spec = wav_to_spec_op(audio, hparams=hparams)
  spectrogram_hash = get_spectrogram_hash_op(spec)

  labels, label_weights, onsets, offsets, velocities = sequence_to_pianoroll_op(
      sequence, velocity_range, hparams=hparams)

  length = wav_to_num_frames_op(audio, hparams_frames_per_second(hparams))

  asserts = []
  if hparams.max_expected_train_example_len and is_training:
    asserts.append(
        tf.assert_less_equal(length, hparams.max_expected_train_example_len))

  with tf.control_dependencies(asserts):
    return InputTensors(
        spec=spec,
        spectrogram_hash=spectrogram_hash,
        labels=labels,
        label_weights=label_weights,
        length=length,
        onsets=onsets,
        offsets=offsets,
        velocities=velocities,
        sequence_id=sequence_id,
        note_sequence=sequence)
def preprocess_example ( example_proto , hparams , is_training ) : record = parse_example ( example_proto ) sequence_id = record [ 'id' ] sequence = record [ 'sequence' ] audio = record [ 'audio' ] velocity_range = record [ 'velocity_range' ] wav_jitter_amount_ms = label_jitter_amount_ms = 0 # if there is combined jitter, we must generate it once here if is_training and hparams . jitter_amount_ms > 0 : wav_jitter_amount_ms = np . random . choice ( hparams . jitter_amount_ms , size = 1 ) label_jitter_amount_ms = wav_jitter_amount_ms if label_jitter_amount_ms > 0 : sequence = jitter_label_op ( sequence , label_jitter_amount_ms / 1000. ) # possibly shift the entire sequence backward for better forward only training if hparams . backward_shift_amount_ms > 0 : sequence = jitter_label_op ( sequence , hparams . backward_shift_amount_ms / 1000. ) if is_training : audio = transform_wav_data_op ( audio , hparams = hparams , jitter_amount_sec = wav_jitter_amount_ms / 1000. ) spec = wav_to_spec_op ( audio , hparams = hparams ) spectrogram_hash = get_spectrogram_hash_op ( spec ) labels , label_weights , onsets , offsets , velocities = sequence_to_pianoroll_op ( sequence , velocity_range , hparams = hparams ) length = wav_to_num_frames_op ( audio , hparams_frames_per_second ( hparams ) ) asserts = [ ] if hparams . max_expected_train_example_len and is_training : asserts . append ( tf . assert_less_equal ( length , hparams . max_expected_train_example_len ) ) with tf . control_dependencies ( asserts ) : return InputTensors ( spec = spec , spectrogram_hash = spectrogram_hash , labels = labels , label_weights = label_weights , length = length , onsets = onsets , offsets = offsets , velocities = velocities , sequence_id = sequence_id , note_sequence = sequence )