how do i read multiple audio file from different files name ?
Mostrar comentarios más antiguos
i have a folder about 136 subfolders which have different names
f1
f2
.
.
.
.
f136
and each subfolder has 10 audio file
these audio files have the same name for whole subfolders
f1 [ sa1 sa2 ....... sa10]
f2 [sa1 sa2 .... sa10]
.
.
f136 [sa1 sa2 ... sa10]
so i need to read them in one matrix
can anyone help me
i will be appreciate
1 comentario
Stephen23
el 23 de Dic. de 2020
"so i need to read them in one matrix"
Does your computer have enough memory to store all of the imported data in one array? Or for that matter, in separate arrays?
Respuesta aceptada
Más respuestas (2)
weikang zhao
el 23 de Dic. de 2020
You need a loop body, the loop body continuously generates the path of the audio file.
Run the following script and you will understand.
for i=1:136
for j=1:10
filename=['f',num2str(i),'\sa',num2str(j),'.wav'];
disp(str);
%code to read the audio file %
end
end
have fun!
4 comentarios
Stephen23
el 23 de Dic. de 2020
Where is str defined?
weikang zhao
el 23 de Dic. de 2020
sorry
disp(filename);
rusul a
el 23 de Dic. de 2020
weikang zhao
el 23 de Dic. de 2020
you can get all the names of the subfolder by "dir" function, for example
X=dir;
X will contain information about all subfolders and files in the current folder, X is a struct array, and you can traverse the 'name' field of X.

jibrahim
el 23 de Dic. de 2020
If you have access to Audio Toolbox, there is no need for much custom code to accomplish this. Just use audioDatastore.
From the top folder:
ads = audioDatastore(pwd,'IncludeSubfolders',true);
data = readall(ads);
data is a cell array with the audio from all files. If all entries in data have the same dimensions, you can concatenate the signals in a matrix.
Categorías
Más información sobre Audio I/O and Waveform Generation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!