Use a sound classification model from Teachable Machine to recognise sounds and make Marty respond in Blocks. This uses your computer or tablet's microphone, rather than Marty's noise sensor. Connect Marty when you want the robot to perform an action.
New to Teachable Machine? Start with its videos on gathering samples and training a model. For a model built directly in Blocks, see Machine Learning in Blocks.
Copy the model link, which has the form https://teachablemachine.withgoogle.com/models/…/. You do not need to copy the JavaScript code shown below it.
Paste the shareable link into Paste TM model URL here, then select Load.
Wait for the imported model to appear in the Models list. It is already trained, so you do not need to train it again in Blocks. Keep the same Marty device selected when you return to Code: the imported model belongs to that device in your project.
In Code, choose Machine Learning. Drag Load Machine Learning model into your program and select the imported model from its dropdown. The same block loads both image and sound models. Place it below when green flag clicked, then click the green flag to load it before using the prediction blocks.
Allow Blocks to use your microphone when prompted. Loading a sound model starts classification. Use turn classification off/on to pause or resume it.
The examples below use a model named Sound model with a clap class. Choose your own model and class names. These are alternative ways to respond to a prediction:
Tick the checkbox beside sound label in the palette to display the latest label. It may be empty when no prediction meets the confidence threshold.
Use set confidence threshold to set the minimum confidence needed to report a label. The default is 0.5, or 50%. Increase it to require a more confident prediction, or lower it if your model rarely produces a label.
To keep your imported model and code, save the project from Save/Load.