MATLAB Answers

0

splitting an audio file into 1s, for max, audio files

Asked by fatima alansari on 12 Apr 2019
Latest activity Edited by fatima alansari on 12 Apr 2019
Hello,
I searched for splitting an audio file into smaller audio files in MATLAB, but I couldn't find a clear way to do so.
Is there any way I can follow in MATLAB to split my audio file into smaller audio files where each file does not exceed 1s???
Regards

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Geoff Hayes
on 12 Apr 2019
 Accepted Answer

fatima - you could use audioread to read the data and then split into smaller ~1 second blocks of data. For example,
[y,Fs] = audioread(filename);
n = length(y);
for k = 1:Fs:n
audioBlock = y(k:min(k + Fs - 1, n), :);
% do something with this block
end
Note how we use the sampling frequency Fs (number of samples per second) to make sure that each audio block is of one second duration. We use
min(k + Fs - 1, n)
to handle the last audio block where we might not have Fs samples.
You could then use audiowrite to write the block to file. But do you really want to split the potentially large file into so many smaller ones?

  1 Comment

Thank you Geoff ,
yes I do. I'll tell you why!
I'm working on detecting stuttering syllables in an audio signal.
To do so, I want to split the audio file then check each small file if it has a stutter.
I'll try using cross-correlation to compare the signals to find out which one is with a stutter.
First, I'll try using the way you mentioned in your answer.

Sign in to comment.