繁体   English   中英

从python中的sox获取.wav的持续时间

[英]Get duration of .wav from sox in python

我知道如何在Linux命令中使用sox打印.wav文件的持续时间。

soxi -D input.wav

所以我在python中使用了这种语法。

subprocess.call(['soxi', '-D', input.wav])

但我想将持续时间(秒)保存在变量中。 如何在变量中获取它?

+++++++++++编辑++++++++++++++

使用)

wavduration = subprocess.call(['soxi', '-D', input.wav])
print(wavduration)

输出)

4.000000
0

这不是正确的方法...

Python具有sox包装器,并且具有以下方法。

seconds = sox.file_info.duration('input file name')
print(seconds)

docs https://pysox.readthedocs.io/zh-CN/latest/api.html#module-sox.file_info

pysox https://github.com/rabitt/pysox/blob/master/README.md

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM