python-soundfile
python-soundfile copied to clipboard
Add the number of frames in info
trafficstars
I need to get the number of frames in a file before calling blocks.
That would be nice to either have info.duration as a float or add a num_frames attribute.
As a quick work-around, you can create a SoundFile object (ideally in a with statement), use len() to get the number of frames and then use the blocks() method (instead of the blocks() function).
import soundfile as sf
with sf.SoundFile('myfile.wav') as f:
frames = len(f)
for block in f.blocks(1024):
# do something