I am using a program called pico2wave to create an audio file.
This program can only write to a file and doesn’t support output to stdout.
I have created a symbolic link to /dev/stdout
called pico2wave.wav
.
I am attempting to replicate the behavior of the following shell command:
pico2wave -w pico2wave.wav test!
Which writes the output file to the pico2wave.wav symbolic link, outputting the resulting file to the stdout.
I have done the same in Node.JS, running the command in a child process but I don’t get any output on the standard output.
const pico2wave = spawn("pico2wave", [
'-w', `${path.join(__dirname, 'pico2wave.wav')}`,
'test!',
], {
stdio: ['ignore', 'pipe', 'pipe']
});
pico2wave.stderr.on("data", (chunk) => {
console.log(chunk.toString());
});
pico2wave.stdout.on('data', (data) => {
console.log(data);
})
Reading the documentation,
‘pipe’: Create a pipe between the child process and the parent process. The parent end of the pipe is exposed to the parent as a property on the child_process object as subprocess.stdio[fd]. Pipes created for fds 0, 1, and 2 are also available as subprocess.stdin, subprocess.stdout and subprocess.stderr, respectively. These are not actual Unix pipes and therefore the child process can not use them by their descriptor files, e.g. /dev/fd/2 or /dev/stdout.
it says, that the child process cannot use /dev/stdout
, rendering my way of doing things flawed, is there a workaround to this issue?
I have also attempted to call pico2wave
through the sh
command, however it didn’t resolve the issue.