Closed guy16510 closed 7 years ago
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
yepp me too. win 10 node v4.2.4
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
I am having the same error, has anyone already fixed this issue? I am not sure where and how to change the code.
same error
I have the same error :( anyone?
same error.
annoying errror
still unresolved
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!
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 :(
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.
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.
Hi, I added a pull-request for what works fine for me: https://github.com/gillesdemey/node-record-lpcm16/pull/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. ;)
@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.
@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
I'm having the issue @freund17 was having. Help is getting dumped. https://github.com/gillesdemey/node-record-lpcm16/issues/42
I added a PR like -- ages ago -- https://github.com/gillesdemey/node-record-lpcm16/pull/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.
@freund17 Ah so the PR hasen't been accepted yet? Damn.. I'll have a look^^
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);
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
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. !!
Ok, To anyone who still has this issue.
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
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
The change @Esinko recommended worked. Please integrate into the main branch!
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 ?
Do you have sox installed and added to env variables?
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
If you're on MacOS and don't have sox installed yet, just do the following:
brew update && brew install sox
It has to be a sox issue, Try using the command the code executes
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.