Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: spawn rec ENOENT #8

Closed
guy16510 opened this issue Dec 23, 2015 · 29 comments
Closed

Error: spawn rec ENOENT #8

guy16510 opened this issue Dec 23, 2015 · 29 comments

Comments

@guy16510
Copy link

Good Morning, I have been stepping through this all yesterday and today, and from what I can tell, there might be an issue with spawn:

index.js - line44
rec = spawn(cmd, cmdArgs);

spawn calls this file: child_process.js @line: 990
var spawn = exports.spawn = function(/file, args, options/) { //These are commented out

I see that spawn doesn't take any arguments?

I am on windows 10
node v.0.12.7

I wanted to see if you gentleman ran into this? Thank you for your help.

@luiselizondo
Copy link

I'm getting a similar error, if not the same

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn rec ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3

@miduku
Copy link

miduku commented Jan 18, 2016

yepp me too.
win 10
node v4.2.4

@CodeHipster
Copy link

It appears rec is no longer shipped with sox.

http://superuser.com/questions/192327/how-can-i-record-sound-from-the-windows-command-line

new command should be like:
sox --type waveaudio --default−device filename.wav

@spoggie
Copy link

spoggie commented Sep 6, 2016

I am having the same error, has anyone already fixed this issue?
I am not sure where and how to change the code.

@johnsonreyliu
Copy link

same error

@linhdoha
Copy link

I have the same error :( anyone?

@victoryforphil
Copy link

same error.

@asheesh-bisht
Copy link

annoying errror

@asheesh-bisht
Copy link

still unresolved

@freund17
Copy link

I got it running for me:
First you add your install-directory ("C:\Program Files (x86)\sox-14-4-2" in my case) to your Path.
You will notice, that there is no rec.exe. So we have to record with sox.exe directly (see comment by @CodeHipster)
Therefore you will need to go into the index.js (of node-record-lpcm16) and replace the cmd-name with "sox" and add the necessary args. It should look something like this:

  var cmd = 'sox';
  var cmdArgs = [
    '-q',                                     // show no progress
    '-t', 'waveaudio',                        // input-type
    '-d',                                     // use default recording device
    '-r', options.sampleRate.toString(),      // sample rate
    '-c', '1',                                // channels
    '-e', 'signed-integer',                   // sample encoding
    '-b', '16',                               // precision (bits)
    '-t', 'raw',                              // output-type
    '-'                                       // pipe
  ];

Yeah... and the options weren't linked to the sample rate.

Have a nice day!

@gillesdemey
Copy link
Owner

You can specify the recordProgram option, I've added sox as an alias to rec for Windows platforms. Unfortunately I don't have a Windows device to test this on :(

https://github.com/gillesdemey/node-record-lpcm16#options

@freund17
Copy link

Hi,
I just saw in your commit. You forgot to add the extra parameters. (Refering to my previous comment here)

'-t', 'waveaudio',                        // input-type
'-d',                                     // use default recording device

Also, for my application I used raw as audio type. Would it be possible to have that as an option? As well as the bit-depth (precision)?
Also we (the windows users) need an option to enter the complete cmd-path. Otherwise it should be added to the readme that sox.exe has to be in the PATH for this module to work.

@nathanosdev
Copy link

Has this been tested on Windows yet? It seems to be running fine and even generates an audio file. But the audio file is unplayable/corrupt.

@freund17
Copy link

Hi,
I added a pull-request for what works fine for me: #28

My test-code:

var record = require('node-record-lpcm16');
var fs = require('fs');

var file = fs.createWriteStream('test.wav', {
    encoding: 'binary'
});

record.start({
    recordProgram: 'sox'
}).pipe(file);

// Stop recording after three seconds
setTimeout(function () {
  record.stop()
}, 3000);

Remember to have sox in PATH.

@AnimaMundi Did you try opening your file with a text-editor? Pretty sure sox just dumped its help-page because of the wrong cmd-args. ;)

@nathanosdev
Copy link

@freund17 thanks for getting back, but unfortunately I'm under time restraints at the moment so I moved on from this when I couldn't get it working within a few hours and ended up using the node-microphone package instead.

@avinash2fly
Copy link

@freund17 code works, but i am not able to play the recorded file as it says it is corrupted and I can see the english content when i opened it in text editor

@basickarl
Copy link

basickarl commented Sep 26, 2017

I'm having the issue @freund17 was having. Help is getting dumped. #42

@freund17
Copy link

I added a PR like -- ages ago -- #28 you should give it a try.
I don't remember any more, but I'm pretty sure the problem with the text comes from sox dumping its help because it is being called with the wrong arguments. (The provided args are for rec)

The version in my PR worked for me (sox, windows, node 5?) -- at least at the time.

@basickarl
Copy link

@freund17 Ah so the PR hasen't been accepted yet? Damn.. I'll have a look^^

@domorso
Copy link

domorso commented Oct 2, 2017

Hi, I use this code

record
.start({
sampleRateHertz: sampleRateHertz,
threshold: 0,
sampleRate : 16000,
// Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
verbose: false,
recordProgram: 'sox', // Try also "arecord" or "sox"
silence: '3.0'
})
.on('error', console.error)
.pipe(recognizeStream);

  • nodejs v4.8.4
  • sox-14-4-2
  • Win 10

on linux i put recordProgram: 'rec' works.
on windows recordProgram: 'sox' does not work (it is as if the sound from the microphone did not come).
Sox it's installed. If I try to run sox in this way "sox -t waveaudio -d prova.flac" works

Do I have to enter the channel or device? I tried but did not go.
Could you suggest me something? Thanks

@ShooterArk
Copy link

I am still facing this issue. I have installed SOX and placed its location in the Path variable but still getting the "Spawn Sox Enonet" error. !!

@Esinko
Copy link

Esinko commented Feb 1, 2019

Ok, To anyone who still has this issue.

  1. Got to your node_modules folder and look for node-record-lpcm16
  2. open index.js of node-record-lpcm16
  3. Look for this in the code:
    case 'rec':
    default:
    cmd = options.recordProgram
    cmdArgs = [
    '-q', // show no progress
    '-r', options.sampleRate, // sample rate
    '-c', options.channels, // channels
    '-e', 'signed-integer', // sample encoding
    '-b', '16', // precision (bits)
    '-t', 'wav', // audio type
    '-', // pipe
    // end on silence
    'silence', '1', '0.1', options.thresholdStart || options.threshold + '%',
    '1', options.silence, options.thresholdEnd || options.threshold + '%'
    ]
    break
  4. Replace it with:
    case 'rec':
    default:
    var cmd = 'sox';
    var cmdArgs = [
    '-q', // show no progress
    '-t', 'waveaudio', // input-type
    '-d', // use default recording device
    '-r', options.sampleRate.toString(), // sample rate
    '-c', '1', // channels
    '-e', 'signed-integer', // sample encoding
    '-b', '16', // precision (bits)
    '-t', 'raw', // output-type
    '-' // pipe
    ];
    break
  5. Save it, correct the tabs and you are done!

@dxh9845
Copy link

dxh9845 commented Mar 19, 2019

The change @Esinko recommended worked. Please integrate into the main branch!

@Laxmikant04
Copy link

hi @Esinko ,

I updated my index,js file as mentioned --

case 'rec':
default:
var cmd = 'sox';
var cmdArgs = [
'-q', // show no progress
'-t', 'waveaudio', // input-type
'-d', // use default recording device
'-r', options.sampleRate.toString(), // sample rate
'-c', '1', // channels
'-e', 'signed-integer', // sample encoding
'-b', '16', // precision (bits)
'-t', 'raw', // output-type
'-' // pipe
];
break

But still i am getting same error -
events.js:174
throw er; // Unhandled 'error' event
^

Error: spawn sox ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19

i am using below code--

'use strict'

var record = require('node-record-lpcm16');
var fs = require('fs')

var file = fs.createWriteStream('test.wav', { encoding: 'binary' })

record.start({
sampleRate: 44100,
verbose: true
})
.pipe(file)

Currently i am working on Windows 10 .

Could you please suggest on what is going wrong ?

@Esinko
Copy link

Esinko commented Jun 13, 2019

Do you have sox installed and added to env variables?

@Laxmikant04
Copy link

hi @Esinko ,

Yes , i have installed sox and added to path -

set path
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\nodejs;C:\Program Files (x86)\sox-14-4-2;C:\Users\laxmikantm\AppData\Local\Programs\Python\Python37\Scripts;

current update - i passed option parameters as {shell: true} instead of { encoding: 'binary' } , NOw i am not getting error but it does not records audio . i mean , it completes code execution immediately

@marcosdiasdev
Copy link

If you're on MacOS and don't have sox installed yet, just do the following:

brew update && brew install sox

@Esinko
Copy link

Esinko commented Jul 17, 2019

It has to be a sox issue, Try using the command the code executes

@gillesdemey
Copy link
Owner

Fixed in #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests