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
used npm install lame in my package.setting to get it installed. Writing a function to take msg.payload which is an object that contains the wav file contents to encode into a mp3. When trying to create a new instance of lame.Encoder, I get the following error:TypeError: Cannot read property 'Encoder' of undefined. Can't get past the creation of lame.Encoder!!! Even after I get past this problem, hoping the encoder will take a java object in and out.
here is the code in the node red function node:
var lame = global.get('lame');
(can't use require in nodes, must set up as a global function in node-red setting) and then call global.get.
// create the Encoder instance
var encoder = new lame.Encoder({
// input
channels: 1, // 2 channels (left and right)
bitDepth: 16, // 16-bit samples
sampleRate: 22050, // 44,100 Hz sample rate
Inside of node-red which is an ESB of sorts. you can't use require. You have to set up modules with a call to global.get so the model is known to all flows. Node-Red uses Node.js as a container and I was hoping I could leverage this npm to encode stuff. Looks like there are some incompatibilities with this code and node red's use of node.js.
used npm install lame in my package.setting to get it installed. Writing a function to take msg.payload which is an object that contains the wav file contents to encode into a mp3. When trying to create a new instance of lame.Encoder, I get the following error:TypeError: Cannot read property 'Encoder' of undefined. Can't get past the creation of lame.Encoder!!! Even after I get past this problem, hoping the encoder will take a java object in and out.
here is the code in the node red function node:
var lame = global.get('lame');
(can't use require in nodes, must set up as a global function in node-red setting) and then call global.get.
// create the Encoder instance
var encoder = new lame.Encoder({
// input
channels: 1, // 2 channels (left and right)
bitDepth: 16, // 16-bit samples
sampleRate: 22050, // 44,100 Hz sample rate
// output
bitRate: 48,
outSampleRate: 16000,
// mode: lame.STEREO // STEREO (default), JOINTSTEREO, DUALCHANNEL or MONO
});
// raw PCM data from stdin gets piped into the encoder
var newmsg = {filename: msg.filename};
var input = msg.payload;
input.pipe(encoder);
//node.log("got past first stage");
// the generated MP3 file gets piped to stdout
encoder.pipe(newmsg.payload);
return newmsg;
The text was updated successfully, but these errors were encountered: