[英]Get duration of .wav from sox in python
I know how to print the duration of the .wav file using sox at the Linux command. 我知道如何在Linux命令中使用sox打印.wav文件的持续时间。
soxi -D input.wav
So I used this syntax in python. 所以我在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... 这不是正确的方法...
Python has sox wrapper and it has following method. Python具有sox包装器,并且具有以下方法。
seconds = sox.file_info.duration('input file name')
print(seconds)
docs https://pysox.readthedocs.io/en/latest/api.html#module-sox.file_info docs https://pysox.readthedocs.io/zh-CN/latest/api.html#module-sox.file_info
pysox https://github.com/rabitt/pysox/blob/master/README.md pysox https://github.com/rabitt/pysox/blob/master/README.md
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.