new TensorflowMusiCNN()

Description

Class with methods for computing inference of Essentia-Tensorflow.js MusiCNN-based pre-trained models. The predict method expect an input audio feature computed using EssentiaTFInputExtractor.

Examples
// FEATURE EXTRACTION
			// Create `EssentiaTFInputExtractor` instance by passing
			// essentia-wasm import `EssentiaWASM` global object and `extractorType=musicnn`.
			const inputFeatureExtractor = new EssentiaTFInputExtractor(EssentiaWASM, "musicnn");
			// Compute feature for a given audio signal
			let inputMusiCNN = inputFeatureExtractor.computeFrameWise(audioSignal);
			// INFERENCE
			const modelURL = "./autotagging/msd/msd-musicnn-1/model.json"
			// Where `tf` is the global import object from the `@tensorflow/tfjs*` package.
			const musicnn = new TensorflowMusiCNN(tf, modelURL);
			// Promise for loading the model
			await musicnn.initialize();
			// Compute predictions for a given input feature.
			let predictions = await musicnn.predict(inputMusiCNN);

Methods


<async> initialize()

Description

Promise for loading & initialise an Essentia.js-TensorFlow.js model.


arrayToTensorAsBatches( inputFeatureArray, inputShape, patchSize [, zeroPadding ] ) → {tf.Tensor3D}

Description

Converts an input 1D or 2D array into a 3D tensor (tfjs) given it's shape and required patchSize. If padding=true, this method will zero-pad the input feature.

Parameters
Name Type Attributes Default Description
inputFeatureArray Float32Array | Array.<any>

input feature array as either 1D or 2D array

inputShape Array.<any>

shape of the input feature array in 2D.

patchSize number

required patchSize to dynamically make batches of feature

zeroPadding boolean <optional>
false

whether to enable zero-padding if less frames found for a batch.

Returns

returns the computed frame-wise feature for the given audio signal.


predict( inputFeature [, zeroPadding ] ) → {array}

Description

Run inference on the given audio feature input and returns the activations

Parameters
Name Type Attributes Default Description
inputFeature InputMusiCNN

audio feature required by the MusiCNN model.

zeroPadding boolean <optional>
false

whether to do zero-padding to the input feature.

Returns

activations of the output layer of the model