Skip to content

Commit

Permalink
minor improvements to TM sound example
Browse files Browse the repository at this point in the history
This includes a separation of `model.json` and the model url to match the TM interface as well as a DOM element with instructions to "clap."
  • Loading branch information
shiffman authored and bomanimc committed Nov 4, 2020
1 parent 213f874 commit 411d772
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/p5js/TeachableMachine/SoundModel_TM/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ Webcam Image Classification using a pre-trained customized model and p5.js
This example uses p5 preload function to create the classifier
=== */

// Global variable to store the classifier
let classifier;

// Label (start by showing listening)
let label = "listening";

// Teachable Machine model URL:
const soundModelURL = 'https://teachablemachine.withgoogle.com/models/h3p9R41J/model.json';
const soundModelURL = 'https://teachablemachine.withgoogle.com/models/h3p9R41J/';


function preload() {
// Load the model
classifier = ml5.soundClassifier(soundModelURL);
classifier = ml5.soundClassifier(soundModelURL + 'model.json');
}

function setup() {
createCanvas(320, 240);
createP("Clap your hands!");
// Start classifying
// The sound model will continuously listen to the microphone
classifier.classify(gotResult);
Expand All @@ -50,4 +50,4 @@ function gotResult(error, results) {
// The results are in an array ordered by confidence.
// console.log(results[0]);
label = results[0].label;
}
}

0 comments on commit 411d772

Please sign in to comment.