How can I slice an audio from the front, and extract and save audio from the back.

5 ビュー (過去 30 日間)
whalelady
whalelady 2020 年 4 月 7 日
回答済み: Ameer Hamza 2020 年 4 月 7 日
I have an audio file and I wish to slice the audio from the front and extract and save the audio from the back.
Let say I have a raw audio file of 20 seconds,
I want to delete everything from the start till 4 seconds,
and keep and save 5 seconds to 20 seconds, making it 16 seconds in the new saved audio file?
Could someone help with this? The below code is what I think may work, do correct my code.
filename='extension'
[y, fs]=audioread(filename);
samples=[0,length(y)-(4*fs)];
[y1,fs] = audioread(filename,samples);
audiowrite('cutversion',y1,fs);
save([extension '.wav'],'cutversion')

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 7 日
You can just delete the initial part of the audio signal and save it into the audio file. For example
[s, fs] = audioread('sample.wav');
s2 = s;
s2(1:2*fs) = [];
audiowrite('new_file.wav', s2, fs);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by