Error using extract Expected audioIn to be one of these types: single, double Instead its type was cell. Error in audioFeatureExtractor/extract (line 626) valid
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
% data store
ADS = audioDatastore('D:\sridhar\reference paper\data','FileExtensions','.wav','IncludeSubfolders',true);
data1 = readall(ADS);
Fs=48000;
% seperating the digits
zero={};
one={};
two={};
three={};
four={};
five={};
six={};
seven={};
eight={};
nine={};
for i=1:500
if(i<=50)
zero= [zero (data1{i,1})];
elseif(i>50 && i<=100)
one=[one (data1{i,1})]
elseif(i>100 && i<=150)
two =[two (data1{i,1})]
elseif(i>150 && i<=200)
three =[three (data1{i,1})]
elseif(i>200 && i<=250)
four =[four (data1{i,1})]
elseif(i>250 && i<=300)
five =[five (data1{i,1})]
elseif(i>300 && i<=350)
six =[six (data1{i,1})]
elseif(i>350 && i<=400)
seven =[seven (data1{i,1})]
elseif(i>400 && i<=450)
eight =[eight (data1{i,1})]
elseif(i>450 && i<=500)
nine =[nine (data1{i,1})]
end
end
% labeling the digits
zeroLabels = repelem(categorical("zero"),1,50);
oneLabels = repelem(categorical("one"),1,50);
twoLabels = repelem(categorical("two"),1,50);
threeLabels = repelem(categorical("three"),1,50);
fourLabels = repelem(categorical("four"),1,50);
fiveLabels = repelem(categorical("five"),1,50);
sixLabels = repelem(categorical("six"),1,50);
sevenLabels = repelem(categorical("seven"),1,50);
eightLabels = repelem(categorical("eight"),1,50);
nineLabels = repelem(categorical("nine"),1,50);
% audio training data
audioTrain = [zero(1:40),one(1:40),two(1:40),three(1:40),four(1:40),five(1:40),six(1:40),seven(1:40),eight(1:40),nine(1:40)];
labelsTrain = [zeroLabels(1:40),oneLabels(1:40),twoLabels(1:40),threeLabels(1:40),fourLabels(1:40),fiveLabels(1:40),sixLabels(1:40),sevenLabels(1:40),eightLabels(1:40),nineLabels(1:40)];
% validation data
audioValidation = [zero(41:end),one(41:end),two(41:end),three(41:end),four(41:end),five(41:end),six(41:end),seven(41:end),eight(41:end),nine(41:end)];
labelsValidation =[zeroLabels(41:end),oneLabels(41:end),twoLabels(41:end),threeLabels(41:end),fourLabels(41:end),fiveLabels(41:end),sixLabels(41:end),sevenLabels(41:end),eightLabels(41:end),nineLabels(41:end)];
% aFE = audioFeatureExtractor("SampleRate",Fs, ...
% "SpectralDescriptorInput","melSpectrum", ...
% "spectralCentroid",false, ...
% "spectralSlope",true, ...
% "mfcc",true);
featuresTrain = extract(aFE,audioTrain);
[numHopsPerSequence,numFeatures,numSignals] = size(featuresTrain)
0 comentarios
Respuestas (1)
Suraj Kumar
el 24 de Feb. de 2025
The error message you're encountering indicates that the extract function is expecting the input audioIn to be of type single or double, but it's being passed a cell array instead.
Here's how you can address this issue:
1.You can convert cell arrays to matrices if they are of the same length.
2. Alternatively, you can iterate over each signal to process them individually.You can refer to the following code snippet for better understanding:
aFE = audioFeatureExtractor("SampleRate",Fs, ...
"SpectralDescriptorInput","melSpectrum", ...
"spectralCentroid",false, ...
"spectralSlope",true, ...
"mfcc",true);
featuresTrain = cell(1, length(audioTrain));
for i = 1:length(audioTrain)
audioSignal = audioTrain{i};
audioSignal = double(audioSignal);
featuresTrain{i} = extract(aFE, audioSignal);
end
Happy Coding!
0 comentarios
Ver también
Categorías
Más información sobre Speech Recognition en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!