#Play audio depending on what object class is detected

8 messages · Page 1 of 1 (latest)

plucky relic
#

Sure, this can be achieved using scripting

gleaming bear
plucky relic
#

I would suggest asking ChatGPT - it writes code pretty good for LS

gleaming bear
#

okay thank youuu!

gleaming bear
#

I can't seem to make it work. There is no error on the code but it still won't work properly

gleaming bear
#

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;