My P5 sketch:

https://editor.p5js.org/JiawenW/sketches/eerX4y8Ee

Documentation Video:

https://youtu.be/mj5Y5UpGpnw

In this project I want to use the Audio Teachable Machine to make a simple voice control game.

I adapted this framework of code form Dan Shirffmen https://www.youtube.com/watch?v=TOrVsLklltM&t=566s

The code contains 4 major parts: connecting the p5 to teachable machine, the UI, spaceship movement, and rock spawn. Loading teachable machine model is somehow very challenging, I tried a couple of different variation of classifier.classify(gotResult), different demo sketch, and changed the version of ml5 library to make it right. The rest of spaceship movement and game logic is relatively easy for me as I made some small games in unity before.

The tricky part is to tweak the confidence level to change the movement, as the teachable machine model is not so stable. I also need to deal with the delay, but didn’t come up with anything helpful, so I the future I might improve this part to make the game smoother.