Undefined function 'preprocessAudio' for input arguments of type 'single'
1 次查看(过去 30 天)
显示 更早的评论
Dear all Coding Experts in Matlab.
I am trying to Train Generative Adversarial Network (GAN) for Sound Synthesis.
But while operating perfor i am getting following error.
for the parfor-loop that is trying to execute on the worker could not be found.
Caused by:
Undefined function 'preprocessAudio' for input arguments of type 'single'.
Error using remoteParallelFunction
Worker unable to find file.
Undefined function 'preprocessAudio' for input arguments of type 'single'.
What Am i Doing Wrong ? I am implementing the code as it is.
Here is my code
downloadFolder = 'audio_folder';% Some folder that contains 100 audio files type .wav
percussivesoundsFolder = fullfile(downloadFolder);
ads = audioDatastore(percussivesoundsFolder,IncludeSubfolders=true);
fftLength = 256;
win = hann(fftLength,"periodic");
overlapLength = 128;
if canUseParallelPool
pool = gcp;
numPar = numpartitions(ads,pool);
else
numPar = 1;
end
parfor ii = 1:numPar
subds = partition(ads,numPar,ii);
STrain = zeros(fftLength/2+1,128,1,numel(subds.Files));
for idx = 1:numel(subds.Files)
% Read audio
[x,xinfo] = read(subds);
% Preprocess
x = preprocessAudio(single(x),xinfo.SampleRate);
% STFT
S0 = stft(x,Window=win,OverlapLength=overlapLength,FrequencyRange="onesided");
% Magnitude
S = abs(S0);
STrain(:,:,:,idx) = S;
end
Please help. Thank you in Advance.
0 个评论
采纳的回答
Steven Lord
2023-3-9
Look at the Utility Functions section at the end of that example's documentation page. The preprocessAudio function is part of that example and so is not on the MATLAB search path by default. You will need to create a file named preprocessAudio.m in a directory that is on the search path (in the directory whose path is returned by userpath is a good place if you don't already have a folder for the code you're trying to run) and copy that code into it.
Since that uses the trimOrPad utility function also included in that example you'll need to either make a similar trimOrPad.m file or copy the trimOrPad function as a subfunction inside preprocessAudio.m.
3 个评论
Steven Lord
2023-3-10
Still the error remains same as it expects a Single Data type of variable numPar and Double Data Type is generated from the statements given below
No, it's the other way around. As stated in the documentation for the resample function in Signal Processing Toolbox, the first input argument (x) must be of data type double. The code checks whether that first input is a double and in your application it's not. It's single precision. So you need to convert your data to double or find an alternate way to resample your data (perhaps using interp1?)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!