Main Content

Compare Sound Classifier block with Equivalent YAMNet blocks

The Sound Classifier block is equivalent to the cascade of the YAMNet Preprocess block and YAMNet block. The model in this example compares the two implementations and shows their equivalence.

The input to the model is a single-channel audio signal. The signal has a sample rate of 44100 Hz and contains 441 samples per channel. The first branch of the model contains the Sound Classifier block. The second branch of the model contains the YAMNet Preprocess block followed by the YAMNet block.

To use these blocks, a YAMNet pretrained network must be installed in a location on the MATLAB® path. If a pretrained network is not installed, then open and run the model. The software provides a download link. To download the network, click the link and unzip the file to a location on the MATLAB path.

Alternatively, execute the following commands to download and unzip the YAMNet model to your temporary directory.

downloadFolder = fullfile(tempdir,'YAMNetDownload');
loc = websave(downloadFolder,'https://ssd.mathworks.com/supportfiles/audio/yamnet.zip');
YAMNetLocation = tempdir;
unzip(loc,YAMNetLocation)
addpath(fullfile(YAMNetLocation,'yamnet'))

Open and run the model. The Maximum block on each branch computes the maximum value of the vector of music scores predicted on each branch. Plot these maximum values on the Scope block and confirm if they match. Similarly, confirm the equivalence in sound labels shown by the Display blocks.

open_system("compareblocks.slx")
sim("compareblocks.slx")

close_system("compareblocks.slx",0)

See Also

Blocks

Related Topics