class_docstr: A dataset for reading NSynth from Tensorflow Datasets (TFDS).
class_docstr_tok: ["A","dataset","for","reading","NSynth","from","Tensorflow","Datasets","(","TFDS",")","."]
docstr: Provides dataset (audio, labels) of nsynth.
docstr_tok: ["Provides","dataset","(","audio",",","labels",")","of","nsynth","."]
code: 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
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from magenta.models.gansynth.lib import spectral_ops
  import numpy
  import tensorflow.compat.v1
  import tensorflow_datasets
label_desc: Use image node_id 3 for calling the NSynthTfdsDataset obj's underlying member method code with example usage: obj.provide_dataset() and returns: dataset, wave,  one_hot_label