MATLAB: Reading, resampling and writing audio files

resample

I have multiple audio files in one folder having file format like C_01_ECHO_FA.wav, C_01_ECHO_FG.wav, C_01_ECHO_MK.wav, C_01_ECHO_ML.wav and again C_02_ECHO_FA.wav, C_02_ECHO_FG.wav, C_02_ECHO_MK.wav, C_02_ECHO_ML.wav and so on like this… The sampling freq of these files are 48k. I need to read all the audio files one by one and resample them to 8k and then write all output audio files in different folder. For the single file, i did like this but i need to do for all. [y,Fs] = audioread('C_01_ECHO_FA.wav'); y_resamp = resample(y,8000,48000); audiowrite('C_01_ECHO_FA_new.wav',y_resamp,8000);

Best Answer

This should do what you want.
[y,fs]=audioread('file48000.wav'); audiowrite('file8000.wav',y,8000);
Related Question