Uploaded model: Error: Mismatch between the last dimension of model's output shape (20) and number of words (2)

I have started exploring Tensorflow.js and have built a speech-commands example that is based on TensorFlow.js Speech Commands Model Demo

Creating and using a model using transfer learning works great. It is able to detect the new commands I say correctly.

What does not work is downloading a model and uploading it again.

When I download a model with 2 words in it (including background noise), and upload the file again, the countExamples() function of the transferRecognizer shows the correct words, so I have the idea the model has loaded correctly.

However as soon as I start using it, I get the following error

speech-commands.esm.js:17 Uncaught (in promise) Error: Mismatch between the last dimension of model’s output shape (20) and number of words (2).
at t. (speech-commands.esm.js:17)

Indeed, when I make a model with 20 words (including background noise), download it and upload it again, the model runs without generating this error, but this is not really what I want.

I have a hunch that the 20 is based on the default ‘18w’ that tensorflowjs provides.

Am I overlooking something? Should I set the number of words in an uploaded model for example?

I had that problem until I looked at https://github.com/googlecreativelab/teachablemachine-community/blob/master/snippets/markdown/audio/tensorflowjs/javascript.md

which passes undefined in the following:

const recognizer = speechCommands.create(
            "BROWSER_FFT", // fourier transform type, not useful to change
            undefined, // speech commands vocabulary feature, not useful for your models
            checkpointURL,
            metadataURL);

https://github.com/tensorflow/tfjs-models/blob/master/speech-commands/README.md states the default is to add 18 words.

Thanks for the tip. I will investigate.