Reputation: 51
I know how to print the duration of the .wav file using sox at the Linux command.
soxi -D input.wav
So I used this syntax in python.
subprocess.call(['soxi', '-D', input.wav])
But I'd like to save the duration(seconds) in a variable. How do I get it in a variable?
+++++++++++ edit ++++++++++++++
using)
wavduration = subprocess.call(['soxi', '-D', input.wav])
print(wavduration)
output)
4.000000
0
This is not the right way to do it...
Upvotes: 1
Views: 3793
Reputation: 267
Python has sox wrapper and it has following method.
seconds = sox.file_info.duration('input file name')
print(seconds)
docs https://pysox.readthedocs.io/en/latest/api.html#module-sox.file_info
pysox https://github.com/rabitt/pysox/blob/master/README.md
Upvotes: 4