%% Increase Time Resolution of VGGish Features
% Create a 10-second pink noise signal and then extract VGGish features. The vggishFeatures function extracts features from mel spectrograms with 50% overlap.

fs = 16e3;
dur = 10;

audioIn = pinknoise(dur*fs,1,'single');

features = vggishFeatures(audioIn,fs);

%
% Plot the VGGish features over time.

surf(features,'EdgeColor','none')
view([30 65])
axis tight
xlabel('Feature Index')
ylabel('Frame')
xlabel('Feature Value')
title('VGGish Features')

%
% To increase the resolution of VGGish features over time, specify the percent overlap between mel spectrograms. Plot the results.

overlapPercentage = 75;
features = vggishFeatures(audioIn,fs,'OverlapPercentage',overlapPercentage);

surf(features,'EdgeColor','none')
view([30 65])
axis tight
xlabel('Feature Index')
ylabel('Frame')
zlabel('Feature Value')
title('VGGish Features')

% Copyright 2020 The MathWorks, Inc.