Wednesday 17 May 2017

Unable to record audio using NodeJS on Linux VPS

i am using node-record lpcm 16 module for recording audio it works very well on MacOS but when i run the same script on my vps that has ubuntu on it then the script is not executing the 'on(data)' callback it directly goes to 'on(finish)' callback i have installed the sox on the server my script is given below

var file_name = Date.now();
var file = fs.createWriteStream(file_name + '.wav', { encoding: 'binary' })
record.start({
//sampleRate: 44100,
//verbose: true
sampleRate: 16000,
compress: true,
threshold: 0.5,
thresholdStart: null,
thresholdEnd: null,
silence: '1.0',
verbose: false,
recordProgram: 'rec' // Defaults to 'rec' - also supports 'arecord' and 'sox'
//device : null // recording device (e.g.: 'plughw:1')
}).on('data',function()
{
console.log("writing data")
}).on('end',function()
{
console.log("end recording ")
})
.on('finish',function ()
{

 console.log("finished") 
 console.log(file_name)
 }).pipe(file)

Thanks!



via Danish

No comments:

Post a Comment