By using excel file name of audio file, i want to filter mixed male audio & female from same directory.
Read mix file name from xlsx and saparate mixed files
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, everyone i am new here. I want to saprate multiple audio files of male & female from one directory. I have one excel file with 2 coulms file name & Label(male/female). I want to saprate male audio into another directory & female audio as well.. Kindly let me know & share script /code to resolve this issue please.
回答 (1 件)
Tejas
2024 年 12 月 27 日
編集済み: Tejas
2024 年 12 月 27 日
Hello Azmat,
It seems that you have a folder containing audio files, along with an Excel sheet that indicates whether each audio file contains either male or female audio, and the goal is to organize these files into separate directories based on gender.
Here are the steps to accomplish this:
- Begin by reading the Excel file using the 'readtable' function. More information about this function can be found in this documentation: https://www.mathworks.com/help/matlab/ref/readtable.html
audioDir = 'pathToAudioDir';
excelFile = 'pathToExcelFile';
fileTable = readtable(excelFile);
- Create separate directories for storing male and female audio files using the 'mkdir' function. This documentation provides more information on how to use the function: https://www.mathworks.com/help/matlab/ref/mkdir.html
maleDir = fullfile(audioDir, 'male');
femaleDir = fullfile(audioDir, 'female');
mkdir(maleDir);
mkdir(femaleDir);
- Go through each row of the Excel sheet and move the audio files to their respective directories using the 'movefile' function. Further details about the function are available in this documentation: https://www.mathworks.com/help/matlab/ref/movefile.html
for i = 1:height(fileTable)
fileName = fileTable.FileName{i}; % Assuming the column name is 'FileName'
label = fileTable.Label{i}; % Assuming the column name is 'Label'
sourceFile = fullfile(audioDir, fileName);
if strcmpi(label, 'male')
destDir = maleDir;
else
destDir = femaleDir;
end
movefile(sourceFile, destDir);
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!