'Ideas for extracting a portion of a wav file and saving as new wav file in MATLAB

This may be easy but I'm no expert in MatLab. I have a bacth of wav files and I need to extract a 30s sample from each. Example:

1.wav - need 1:34-2:04

2.wav - need 5:15 - 5:45

Ideally I'd like to run a code which will take each wav file and extract the correct time period according to a pre-generated table and save each snippet as a new wav file (e.g., 1_snip.wav would be the 30secs I need to analyze). Any points in the right direction would be great. Thanks!



Solution 1:[1]

First you extract raw audio from the recording: [signal,fs] = audioread(‘file.wav’);

The sampling rate is stored inside fs, representing your samples per second. So, 5 seconds would be 5*fs. It is thus possible to extract chunks with specific time stamps: sig_chunk = signal(start_in_s*fs+1 : end_in_s*fs);

It’s also possible to take timestamp data from a table and use the for loop to cut audio.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 petrucci9000