Hi, so basically the code below doesn’t work, I don’t know if it’s the file path, but it cannot load the sound for some reason. Error: There was no response from the server at C:UserslauriDownloadsInput.mp3. Check the url and internet connectivity.
The error stack trace includes: setup@about:srcdoc:83:13
Here is the code:
// The video
let video;
// For displaying the label
let label = "waiting...";
// The classifier
let classifier;
let modelURL = 'https://teachablemachine.withgoogle.com/models/e9uoLktk7/';
// STEP 1: Load the model!
function preload() {
classifier = ml5.imageClassifier(modelURL + 'model.json');
}
function setup() {
createCanvas(640, 520);
// Create the video
video = createCapture(VIDEO);
video.hide();
let mySound;
soundFormats('mp3', 'ogg');
mySound = loadSound("C:\Users\lauri\Downloads\Input.mp3");
// STEP 2: Start classifying
classifyVideo();
}
// STEP 2 classify the videeo!
function classifyVideo() {
classifier.classify(video, gotResults);
}
function draw() {
background(0);
// Draw the video
image(video, 0, 0);
// STEP 4: Draw the label
textSize(32);
textAlign(CENTER, CENTER);
fill(255);
text(label, width / 2, height - 16);
}
// STEP 3: Get the classification!
function gotResults(error, results) {
if (error) {
console.error(error);
return;
}
// Store the label and classify again!
label = results[0].label;
classifyVideo();
}
if (label == "Distracted") {
mySound.play();
}