Hi, I'm trying to get these two platforms to communicate, but I'm stuck.
for instance, to find a way i can execute SF scripts from Python and vice versa.
Do you have any links or resources to help me out?
Thanks,
Udi
- Dustin Harris @Dustin_Harris
I haven't called SoundFlow from python, but I have called python scripts from soundflow, which is pretty simple:
function runPythonScript({ scriptPath, option1, option2, inputPath, outputPath }) { const result = sf.system.exec({ commandLine: `arch -arm64 python3 "${scriptPath}" -option_1 ${option1} -option_2 ${option2} '${inputPath}' '${outputPath}'` }); while (!result) sf.wait({ intervalMs: 50 }); if (result.exitCode > 0) throw `Error Processing Python Script\nExit Code: ${result.exitCode}\nStandardError:\n${result.standardError}`; }
I recently switch to using a virtual environment for it too but I can't seem to find the
sf.system.exec
call for that, but it would be whatever commands you need to execute in the terminal :)Christian Scheuer @chrscheuer2024-03-13 18:07:53.497Z
And for the other way around:
- In reply toDustin_Harris⬆:UUdi Simhon @Udi_Simhon
Thanks @Dustin_Harris !
I'm not sure where to write the path to the .py file.
also, can you explain the 'option1, option2, inputPath, outputPath' use?Dustin Harris @Dustin_Harris
Hi @Udi_Simhon
I made that function with all of those parameters because I need to pass those inputs to my python script (which processes some audio) so here's an example of how I use it:function runPythonScript({ scriptPath, option1, option2, inputPath, outputPath }) { const result = sf.system.exec({ commandLine: `arch -arm64 python3 "${scriptPath}" -option_1 ${option1} -option_2 ${option2} '${inputPath}' '${outputPath}'` }); while (!result) sf.wait({ intervalMs: 50 }); if (result.exitCode > 0) throw `Error Processing Python Script\nExit Code: ${result.exitCode}\nStandardError:\n${result.standardError}`; } const myPythonScript = "~/Desktop/myFavoritePythonScript.py"; const speed = 2.5; const pitch = 1.1; const fileToProcess = "~/Desktop/someWaveFile.wav"; const processedFile = "~/Desktop/someWaveFile_Processed.wav"; runPythonScript({ scriptPath: myPythonScript, option1: speed, option2: pitch, inputPath: fileToProcess, outputPath: processedFile, });
so, the python script I'm running is made to accept those parameters as well of course, but your needs may vary; you might not need any of the parameters.
Another important note: I'm on an M1 system, so I'm specifyingarch -arm64
to ensure python is running all of its code and modules with the arm64 versions.Dustin Harris @Dustin_Harris
if you only need to run the python script and don't need to pass the python script any parameters, you can use this simpler function instead:
function runPythonScript({ scriptPath }) { const result = sf.system.exec({ commandLine: `arch -arm64 python3 "${scriptPath}"` }); while (!result) sf.wait({ intervalMs: 50 }); if (result.exitCode > 0) throw `Error Processing Python Script\nExit Code: ${result.exitCode}\nStandardError:\n${result.standardError}`; }