#The dataset's audio clips are stored in eight folders corresponding to each speech command: `no`, `yes`, `down`, `go`, `left`, `up`, `right`, and `stop`:
#The audio clips are 1 second or less at 16kHz. The `output_sequence_length=16000` pads the short ones to exactly 1 second (and would trim longer ones) so that they can be easily batched.
#The dataset now contains batches of audio clips and integer labels. The audio clips have a shape of `(batch, samples, channels)`.
train_ds.element_spec
#This dataset only contains single channel audio, so use the `tf.squeeze` function to drop the extra axis:
defsqueeze(audio,labels):
audio=tf.squeeze(audio,axis=-1)
returnaudio,labels
train_ds=train_ds.map(squeeze,tf.data.AUTOTUNE)
val_ds=val_ds.map(squeeze,tf.data.AUTOTUNE)
#The `utils.audio_dataset_from_directory` function only returns up to two splits. It's a good idea to keep a test set separate from your validation set.
#Ideally you'd keep it in a separate directory, but in this case you can use `Dataset.shard` to split the validation set into two halves. Note that iterating over **any** shard will load **all** the data, and only keep its fraction.