Process all files in folder using sprintf and audioread
2 次查看(过去 30 天)
显示 更早的评论
I'm trying to process a sequence .mp3 files with different filenames, and get them to output in a subfolder with incrementing names.
However, the script can only find files with a certain filename structure. How can i use the script on all files in the folder, while using sprintf
to make an input, which is processed by audioread? Lastly, how can i reuse the input filename when adding a digit in the output part? (%d)
Ask if you need more info. I'm quite the beginner here.
numfiles = 600;
mydata = cell(1, numfiles);
FS = 16e3; % sampling rate
for loop = 1:numfiles
input = sprintf('sounds/sentence%d.mp3', loop); % this argument should take all mp3's in folder
[x,fs] = audioread(input);
x = resample(x, FS, fs);
y = vocoder(x, FS, 8, 160, 'NOISE', 1);
CISignal = y * (rms(x)/rms(y));
CISignal = CISignal/max(abs(CISignal(:)))
output = sprintf('sounds/output/sentence%d.wav', loop); %
fprintf('Saving %s\n', output);
audiowrite(output,CISignal,FS);
end
Thanks to everyone who can point in the right direction!
Sorry - but looking through dozens of Answers, none worked when using sprintf and audioread.
2 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!