Audio Cats and Dogs

Dataset consisting of recordings of cats and dogs

The dataset contains 164 recordings of cat sounds (1,323 seconds) and 113 recordings of dog sounds (598 seconds). The length of the recordings is variable.

Examples

Basic Examples

Retrieve the resource:

In[1]:=
ResourceObject["Audio Cats and Dogs"]
Out[2]=

Retrieve the dataset:

In[3]:=
RandomSample[ResourceData["Audio Cats and Dogs"], 5]
Out[4]=

Visualization

Select an entry from the dataset:

In[5]:=
entry = RandomChoice[ResourceData["Audio Cats and Dogs"]]
Out[6]=

Visualize the waveform of the Audio object:

In[7]:=
AudioPlot[entry["Audio"]]
Out[7]=

Visualize the spectrum:

In[8]:=
Periodogram[entry["Audio"], 1000]
Out[8]=

Visualize the spectrogram:

In[9]:=
Spectrogram[entry["Audio"]]
Out[9]=

Analysis

Compute the number of examples per class:

In[10]:=
ResourceData["Audio Cats and Dogs"][Counts, "Label"]
Out[11]=

Inspect the sample rate and channel count of the Audio objects:

In[12]:=
ResourceData[
  "Audio Cats and Dogs"][{DeleteDuplicates@*AudioSampleRate, DeleteDuplicates@*AudioChannels}, "Audio"]
Out[13]=

Plot the histogram of the durations of the Audio objects:

In[14]:=
ResourceData["Audio Cats and Dogs"][Histogram@*Duration, "Audio"]
Out[15]=

By computing the cumulative duration of the labels, it can be seen that the dataset is not balanced:

In[16]:=
GroupBy[ResourceData["Audio Cats and Dogs"], "Label"][All, Total@*Duration, "Audio"]
Out[17]=

The average recording duration for the two labels is different as well:

In[18]:=
{dogDuration, catDuration} = Values@Normal[
   GroupBy[ResourceData["Audio Cats and Dogs"], "Label"][All, Mean@*Duration, "Audio"]]
Out[19]=

Create a balanced training dataset.

In[20]:=
SeedRandom[42];
classLength = 93;
catTrain = RandomSample[
   ResourceData["Audio Cats and Dogs"][Select[#Label === "cat" &]], Round[classLength*dogDuration/catDuration]];
dogTrain = RandomSample[
   ResourceData["Audio Cats and Dogs"][Select[#Label === "dog" &]], classLength];

Make sure that the class total duration of the selected samples is similar:

In[21]:=
catTrain[Total@*Duration, "Audio"]
dogTrain[Total@*Duration, "Audio"]
Out[21]=
Out[22]=

Join the two classes and shuffle the elements:

In[23]:=
balancedTrain = RandomSample[Join[catTrain, dogTrain]];
RandomSample[balancedTrain, 2]
Out[24]=

Create an unbalanced testing dataset using the remaining data:

In[25]:=
unbalancedTest = Complement[ResourceData["Audio Cats and Dogs"], balancedTrain];
In[26]:=
GroupBy[unbalancedTest, "Label"][All, Total@*Duration, "Audio"]
Out[26]=

Wolfram Research, "Audio Cats and Dogs" from the Wolfram Data Repository (2018)  

License Information

https://creativecommons.org/licenses/by-sa/3.0

Data Resource History

Source Metadata

Publisher Information