MTG/essentia.js

TypeError: Cannot convert "undefined" to unsigned int

yashsavla9 opened this issue · 2 comments

What is the issue about?

  • Bug

What part(s) of Essentia.js is involved?

  • essentia.js-core (vanilla algorithms)

Description

TypeError: Cannot convert "undefined" to unsigned int
at Object.toWireType
File essentia.js/dist/essentia-wasm.umd.js:19:2523624

Steps to reproduce / Code snippets / Screenshots

var esLib = require('essentia.js');
const essentia = new esLib.Essentia(esLib.EssentiaWASM);
console.log("essentia.js version: ", essentia.version);
let wav = require('node-wav');
let buffer = fs.readFileSync('./recordings/test.wav');
// Decode wav audio file using node-wav package
let audio = wav.decode(buffer);
// Convert audio data into VectorFloat type
const audioLeftChannelData = essentia.arrayToVector(audio.channelData[0]);
const audioRightChannelData = essentia.arrayToVector(audio.channelData[1]);

// Downmix stereo audio to mono
const audioDownMixed = essentia.MonoMixer(audioLeftChannelData, audioRightChannelData).audio;

// Create overlapping frames of the audio with given frameSize and hopSize
let frames = essentia.FrameGenerator(audioDownMixed,
    1024, // frameSize
    512 // hopSize
);


// Iterate through frames and compute danceability feature
for (var i=0; i < frames.size(); i++) {
    let danceability = essentia.Danceability(frames.get(i)).danceability;
    console.log("Danceability: ", danceability);
};
// delete frames from memmory
frames.delete();

// After the use of essentia.js
essentia.delete();

System info

Macos 11.3.1
Nodejs 14.0.0
essentia.js version: 2.1-beta6-dev

@yashsavla9 Thanks for reporting, found out to be an error in the example code. The error happens because FrameGenerator expects the audio data to be as JS Float32TypedArray (see here).

Have a look at the updated node.js examples.

@yashsavla9 Thanks for reporting, found out to be an error in the example code. The error happens because FrameGenerator expects the audio data to be as JS Float32TypedArray (see here).

Have a look at the updated node.js examples.

Thanks @albincorreya