%% Identify Only Specific Sounds
% Read in an audio signal containing multiple different sound events.

[audioIn,fs] = audioread('multipleSounds-16-16-mono-18secs.wav');

%
% Call classifySound with the audio signal and sample rate.

[sounds,~,soundTable] = classifySound(audioIn,fs);

%
% The sounds string array contains the most likely sound event in each region.

sounds

%
% The soundTable contains detailed information regarding the sounds detected in each region, including score means and maximums over the analyzed signal.

soundTable

%
% View the last detected region.

soundTable.Results{end}

%
% Call classifySound again. This time, set IncludedSounds to Animal so that the function retains only regions in which the Animal sound class is detected.

[sounds,timeStamps,soundTable] = classifySound(audioIn,fs, ...
    'IncludedSounds','Animal');

%
% The sounds array only returns sounds specified as included sounds. The sounds array now contains two instances of Animal that correspond to the regions declared as Bark and Meow previously.

sounds

%
% The sound table only includes regions where the specified sound classes were detected.

soundTable

%
% View the last detected region in soundTable. The results table still includes statistics for all detected sounds in the region.

soundTable.Results{end}

%
% To explore which sound classes are supported by classifySound, use yamnetGraph.
% Copyright 2020 The MathWorks, Inc.