#Play audio depending on what object class is detected
8 messages · Page 1 of 1 (latest)
Is there an example or guide that I can use for it?
I would suggest asking ChatGPT - it writes code pretty good for LS
Or check the scripting API https://docs.snap.com/api/lens-studio/Full-API-List
okay thank youuu!
I can't seem to make it work. There is no error on the code but it still won't work properly
I tried making my own script but it doesn't seem to work
// @input Component.AudioComponent audioFrame
// @input Component.AudioComponent audioGlass
// @input Component.AudioComponent audioLight
// @input Component.AudioComponent audioWindow
var audioTrack = script.audioFrame;
var audioTrack = script.audioGlass;
var audioTrack = script.audioLight;
var audioTrack = script.audioWindow;
var DetectionHelpers = require("DetectionHelpersModule");
function updateDetection(detection) {
var className = detection.label;
switch (className){
case "Picture-Frames":
audioFrame.play(1);
break;
case "Glassware":
audioGlass.play(1);
break;
case "Fluorescent-Lights":
audioLight.play(1);
break;
case "Glass-Windows":
audioWindow.play(1);
break;
default:
}
}
script.updateDetection = updateDetection;