You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running this against a wav file, converting to JSON (using the code from the example in /examples) I receive this error:
Error [ERR_IPC_DISCONNECTED]: IPC channel is already disconnected
at process.target.disconnect (internal/child_process.js:861:26)
at checkWaitingCount (internal/cluster/child.js:209:17)
at Worker._disconnect (internal/cluster/child.js:226:3)
at Worker.onmessage (internal/cluster/child.js:52:19)
at process.onInternalMessage (internal/cluster/utils.js:47:8)
at process.emit (events.js:327:22)
at emit (internal/child_process.js:906:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
Emitted 'error' event on Worker instance at:
at process.<anonymous> (internal/cluster/worker.js:29:12)
at process.emit (events.js:315:20)
at process.target.disconnect (internal/child_process.js:861:12)
at checkWaitingCount (internal/cluster/child.js:209:17)
[... events.js:292
throw er; // Unhandled 'error' event
^
Code:
constconvertAudioFile=(audioFileName)=>{constfileName=audioFileName.split('.')[0]varspectro=newSpectro()varaudioFile=fs.createReadStream(`${__dirname}/data/wav/${fileName}.wav`,{start: 44})// Note: The first 44 bytes are the wav-headerreturnnewPromise((res,rej)=>{// The file stream can simply be piped into the Spectro instanceaudioFile.pipe(spectro)// Check when the file stream completedvarfileRead=falseaudioFile.on('end',()=>{fileRead=true})// The data event can be used to work with recently processed data from the workersspectro.on('data',(err,frame)=>{if(err)rej(err)// frame contains an index of the processed frame and a data section with the processed data})try{spectro.on('end',(err,data)=>{if(err)rej(err)// The 'end' event always fires when spectro has reached the end of the currently processable data// Therefore we should check if the file was read completely before using the dataif(fileRead!==true)returntry{spectro.stop()}catch(e){console.log(e)}// const max = Spectro.maxApplitude(data)// const min = Spectro.minApplitude(data)// console.log(`Max amplitude is ${max}, min amplitude is ${min}`)fs.writeFileSync(`${__dirname}/data/json/${fileName}.json`,JSON.stringify(data),'utf-8');res()})}catch(e){console.log(e)rej(e)}})}
(I've added try/catch, and promises, but it was failing without those)
After a bit of Googling, the error seems to be related to trying to stop the process when it's already stopped. I've tried adding:
if (!worker.exitedAfterDisconnect) {
worker.disconnect()
}
In the Spectrogram.prototype.stop = function()
However this didn't work, tested locally when editing my node_modules.
Thoughts?
The text was updated successfully, but these errors were encountered:
When running this against a wav file, converting to JSON (using the code from the example in /examples) I receive this error:
Code:
(I've added try/catch, and promises, but it was failing without those)
After a bit of Googling, the error seems to be related to trying to stop the process when it's already stopped. I've tried adding:
In the
Spectrogram.prototype.stop = function()
However this didn't work, tested locally when editing my node_modules.
Thoughts?
The text was updated successfully, but these errors were encountered: