Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using python subprocess to call sox

I am trying to use subprocess.call to run a sox command as follows:

import subprocess
subprocess.call(['sox','-n','-b','16','output.wav','synth','2.25','sine','300','vol','0.5'])

While this command works fine on a unix command line, here I get the following error:

OSError: [Errno 2] No such file or directory 

I also tried this using os.system:

os.system('sox -n -b 16 output.wav synth 2.25 sine 300 vol 0.5')

And I get a command not found error. Calling other unix commands works fine for me, e.g.

subprocess.call(['say' ,'hello'])

Any ideas? I'm running OS 10.8.4, python 2.7.6, sox 14.4.1.

like image 688
Jennifer Culbertson Avatar asked May 17 '26 12:05

Jennifer Culbertson


1 Answers

Try using cmdstring = "sox -n -b 16 relative_path/output.wav synth 2.25 sine 300 vol 0.5"

Then calling os.system(cmdstring)

like image 198
Ankit Shah Avatar answered May 20 '26 01:05

Ankit Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!