(self)
return dataset
Provides dataset (audio, labels) of nsynth.
Provides dataset (audio, labels) of nsynth.
Provides dataset ( audio labels ) of nsynth .
def provide_dataset(self):
    """Provides dataset (audio, labels) of nsynth."""
    length = 64000
    channels = 1

    pitch_counts = self.get_pitch_counts()
    pitches = sorted(pitch_counts.keys())
    label_index_table = tf.lookup.StaticVocabularyTable(
        tf.lookup.KeyValueTensorInitializer(
            keys=pitches,
            values=np.arange(len(pitches)),
            key_dtype=tf.int64,
            value_dtype=tf.int64),
        num_oov_buckets=1)

    def _parse_nsynth(example):
      """Parsing function for NSynth dataset."""
      wave, label = example['audio'], example['pitch']
      wave = spectral_ops.crop_or_pad(wave[tf.newaxis, :, tf.newaxis],
                                      length,
                                      channels)[0]
      one_hot_label = tf.one_hot(
          label_index_table.lookup(label), depth=len(pitches))
      return wave, one_hot_label

    dataset = self._get_dataset_from_tfds()
    dataset = dataset.map(
        _parse_nsynth, num_parallel_calls=tf.data.experimental.AUTOTUNE)
    return dataset
def provide_dataset ( self ) : length = 64000 channels = 1 pitch_counts = self . get_pitch_counts ( ) pitches = sorted ( pitch_counts . keys ( ) ) label_index_table = tf . lookup . StaticVocabularyTable ( tf . lookup . KeyValueTensorInitializer ( keys = pitches , values = np . arange ( len ( pitches ) ) , key_dtype = tf . int64 , value_dtype = tf . int64 ) , num_oov_buckets = 1 ) def _parse_nsynth ( example ) : """Parsing function for NSynth dataset.""" wave , label = example [ 'audio' ] , example [ 'pitch' ] wave = spectral_ops . crop_or_pad ( wave [ tf . newaxis , : , tf . newaxis ] , length , channels ) [ 0 ] one_hot_label = tf . one_hot ( label_index_table . lookup ( label ) , depth = len ( pitches ) ) return wave , one_hot_label dataset = self . _get_dataset_from_tfds ( ) dataset = dataset . map ( _parse_nsynth , num_parallel_calls = tf . data . experimental . AUTOTUNE ) return dataset