0

I have a few sample ".ds2" audio files and I need to find the duration of those files. I've done a little bit of research but could not find anything that works for python. Is there any python package or some other way that I can use to get the duration of these files?

ArnabC
  • 181
  • 1
  • 3
  • 16

1 Answers1

-1

You can work with this alternative solution incase you can't find the actual one .

I couldn't find any python module which can read .ds2 files. However, python wave module has the .wav file read capability. Hence convert the .ds2 to .wav .

You can follow this link. The program is as follows.

import wave
import contextlib
fname = '/tmp/test.wav'
with contextlib.closing(wave.open(fname,'r')) as f:
    frames = f.getnframes()
    rate = f.getframerate()
    duration = frames / float(rate)
    print(duration)
McLovin
  • 555
  • 8
  • 20
  • ".wav" is not the problem! I have already calculated the duration of ".wav" format. I need a solution for ".ds2" Anyway, thanks for a solution. – ArnabC Dec 12 '19 at 09:26