()
return [filename_to_id(wav) for wav, _ in test_file_pairs]
Generate the test TFRecord.
Generate the test TFRecord.
Generate the test TFRecord .
def generate_test_set():
  """Generate the test TFRecord."""
  test_file_pairs = []
  for directory in test_dirs:
    path = os.path.join(FLAGS.input_dir, directory)
    path = os.path.join(path, '*.wav')
    wav_files = glob.glob(path)
    # find matching mid files
    for wav_file in wav_files:
      base_name_root, _ = os.path.splitext(wav_file)
      mid_file = base_name_root + '.mid'
      test_file_pairs.append((wav_file, mid_file))

  test_output_name = os.path.join(FLAGS.output_dir,
                                  'maps_config2_test.tfrecord')

  with tf.python_io.TFRecordWriter(test_output_name) as writer:
    for idx, pair in enumerate(test_file_pairs):
      print('{} of {}: {}'.format(idx, len(test_file_pairs), pair[0]))
      # load the wav data and resample it.
      samples = audio_io.load_audio(pair[0], FLAGS.sample_rate)
      wav_data = audio_io.samples_to_wav_data(samples, FLAGS.sample_rate)

      # load the midi data and convert to a notesequence
      ns = midi_io.midi_file_to_note_sequence(pair[1])

      example = audio_label_data_utils.create_example(pair[0], ns, wav_data)
      writer.write(example.SerializeToString())

  return [filename_to_id(wav) for wav, _ in test_file_pairs]
def generate_test_set ( ) : test_file_pairs = [ ] for directory in test_dirs : path = os . path . join ( FLAGS . input_dir , directory ) path = os . path . join ( path , '*.wav' ) wav_files = glob . glob ( path ) # find matching mid files for wav_file in wav_files : base_name_root , _ = os . path . splitext ( wav_file ) mid_file = base_name_root + '.mid' test_file_pairs . append ( ( wav_file , mid_file ) ) test_output_name = os . path . join ( FLAGS . output_dir , 'maps_config2_test.tfrecord' ) with tf . python_io . TFRecordWriter ( test_output_name ) as writer : for idx , pair in enumerate ( test_file_pairs ) : print ( '{} of {}: {}' . format ( idx , len ( test_file_pairs ) , pair [ 0 ] ) ) # load the wav data and resample it. samples = audio_io . load_audio ( pair [ 0 ] , FLAGS . sample_rate ) wav_data = audio_io . samples_to_wav_data ( samples , FLAGS . sample_rate ) # load the midi data and convert to a notesequence ns = midi_io . midi_file_to_note_sequence ( pair [ 1 ] ) example = audio_label_data_utils . create_example ( pair [ 0 ] , ns , wav_data ) writer . write ( example . SerializeToString ( ) ) return [ filename_to_id ( wav ) for wav , _ in test_file_pairs ]