I am trying to get use a python script within my node.js application using the NPM package python-shell. I can run the script from command line using this format on Mac OS.
python3 myScript.py < input.zip > output.wav
However when I try to run the script in my node application I get this error
Error: usage: myScript.py [-h] [-s FACTOR]
myScript.py: error: unrecognized arguments: input output
I get the same error when I remove the < and > from the command in the terminal I have tried to add the < and > to the python-shell options however I get the same error with the < and > included.
Node.js
const input = `input.zip`;
const output = `output.wav`;
const options: any = {
args: [input,output],
pythonOptions: ['-u'],
};
PythonShell.run('myScript.py', options, function (err, results) {
if (err) throw err;
console.log('finished');
console.log(results);
});
myScript.py
def main():
print("started")
global args
args = parse_args()
write_wav(read_chunks(sys.stdin.buffer), sys.stdout.buffer)
if __name__ == '__main__':
main()
I am really unsure what to do to get this working any advice is greatly appreciated.