MATLAB Audio Reformatting: Array dimensions are not consistent

I am working on a deep learning project that identifies words. I am using this as a guide: https://www.mathworks.com/help/audio/ug/Speech-Command-Recognition-Using-Deep-Learning.html

However, when I input my own audio into the code and try to reformat it I keep getting this error...

Error using vertcat Dimensions of arrays being concatenated are not consistent. Error in PLS (line 109) xPadded = [zeros(floor((segmentSamples-size(x,1))/2),1);x;zeros(ceil((segmentSamples-size(x,1))/2),1)];

This is the code where the error is occuring (I am using 16000 hz):

%Sets audio to consistent size
x = read(adsTrain);

numSamples = size(x,1);

numToPadFront = floor( (segmentSamples - numSamples)/2 );
numToPadBack = ceil( (segmentSamples - numSamples)/2 );

xPadded = [zeros(numToPadFront,1,'like',x);x;zeros(numToPadBack,1,'like',x)];



features = extract(afe,xPadded);
[numHops,numFeatures] = size(features)


if ~isempty(ver('parallel')) && ~reduceDataset
    pool = gcp;
    numPar = numpartitions(adsTrain,pool);
else
    numPar = 1;
end


for ii = 1:numPar
    subds = partition(adsTrain,numPar,ii);
    XTrain = zeros(numHops,numBands,1,numel(subds.Files));
    for idx = 1:numel(subds.Files)
        x = read(subds);
    %THIS IS WHERE IS ERROR IS THROWN
    xPadded = [zeros(floor((segmentSamples-size(x,1))/2),1);x;zeros(ceil((segmentSamples-size(x,1))/2),1)]; 
        XTrain(:,:,:,idx) = extract(afe,xPadded);
    end
    XTrainC{ii} = XTrain;
end


XTrain = cat(4,XTrainC{:});

[numHops,numBands,numChannels,numSpec] = size(XTrain)

Thanks!



from Recent Questions - Stack Overflow https://ift.tt/3fNv8iA
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation