Wolfram Computation Meets Knowledge

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[1]=

Retrieve the dataset:

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

Visualization

Select an entry from the dataset:

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

Visualize the waveform of the Audio object:

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

Visualize the spectrum:

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

Visualize the spectrogram:

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

Analysis

Compute the number of examples per class:

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

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

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

Plot the histogram of the durations of the Audio objects:

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

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

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

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

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

Create a balanced training dataset.

In[12]:=
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[13]:=
catTrain[Total@*Duration, "Audio"]
dogTrain[Total@*Duration, "Audio"]
Out[13]=
Out[13]=

Join the two classes and shuffle the elements:

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

Create an unbalanced testing dataset using the remaining data:

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

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