[英]Running `sox.exe` from Python
I run this command from Windows cmd line successfully: 我从Windows cmd行成功运行此命令:
c:\\cygwin\\bin\\sox.exe -r 16000 -c 1 c:/work/out/in_fixed.s32 c:/work/out/out_float.f32
However, I fail to run it from Python: 但是,我无法从Python运行它:
import subprocess
if __name__ == "__main__":
sox = 'c:/cygwin/bin/sox.exe'
in_fixed = 'c:/work/out/in_fixed.s32'
out_float = 'c:/work/out/out_fixed.f32'
cmnd = '-r 16000 -c 1 ' + in_fixed + ' ' + out_float
subprocess.call([sox, cmnd])
Ther error is: 错误是:
/usr/bin/sox FAIL sox: Rate value ` 16000 -c 1 c:/work/out/in_fixed.s32 c:/work/out/out_fixed.f32' is not a positive number.
How to launch this command from python properly? 如何从python正确启动此命令?
Try separating your arguments 尝试分开争论
subprocess.call([sox, '-r', str(16000), '-c', str(1), in_fixed, out_float])
If that doesn't work, you can force CMD usage with shell=True
. 如果这不起作用,则可以通过
shell=True
强制使用CMD。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.