簡體   English   中英

從Python運行`sox.exe`

[英]Running `sox.exe` from Python

我從Windows cmd行成功運行此命令:

c:\\cygwin\\bin\\sox.exe -r 16000 -c 1 c:/work/out/in_fixed.s32 c:/work/out/out_float.f32

但是,我無法從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])

錯誤是:

/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. 

如何從python正確啟動此命令?

嘗試分開爭論

subprocess.call([sox, '-r', str(16000), '-c', str(1), in_fixed, out_float])

如果這不起作用,則可以通過shell=True強制使用CMD。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM