Search code examples
audioclassificationml5.js

How to stop sound classification in ml5.js


Is it possible to programmatically stop sound classification process? I don't find any method or function to do it. Ex:

const classifier = ml5.soundClassifier('path/to/model.json', options, modelReadyCallback);
// start classification
classifier.classify(gotResult);
// but how to stop?
classifier.stop(); // no such method

Reloading the page can solve the problem, but it is not the required solution. Any idea?

Thanks a lot!


Solution

  • This is what I am doing

    classifier.model.model.stopListening()
    

    For the start

    The model includes a "listen" method, however, I have yet to discover the appropriate values for it.

    Recreating the classifier seems to be a solution.