AI DJ: Make Sounds Do Things
- Understand how AI audio recognition converts sound into visual spectrograms for classification
- Train a Teachable Machine audio model with background noise and at least two recognizable sound classes
- Test the model for robustness by attempting to fool it with variations of the same sound
Can AI Really Hear?
AI can hear — but not the way you do. When you hear a clap, your brain processes the sound, recognizes the rhythm and sharpness of the noise, and compares it to all the sounds you have heard before. AI audio recognition works by converting sound into a visual pattern called a spectrogram — a picture of how a sound changes over time. Then it uses image classification on that picture, the same way it classifies photos.
This means you can use the exact same tool you used in the last lesson — Google Teachable Machine — but switch it to audio mode. You will teach it to recognize specific sounds you make, and then wire those sounds up to actions.
This is the technology behind voice assistants, smart home devices, and apps that can identify music from a short clip. Today you are going to use it to build an AI that responds to your commands — no words required.
Set Up Your Sound Project
Go to teachablemachine.withgoogle.com and click Get Started. This time choose Audio Project. You will see three classes to start: Background Noise, Class 1, and Class 2.
The Background Noise class is important — it teaches the AI what silence and normal room sounds look like, so it does not confuse a dog barking outside with your clap command. Record at least 20 seconds of background noise first by clicking Record 20 seconds.
Now rename Class 1 and Class 2 with the sounds you want to recognize. Here are some good choices:
- Clap — short, sharp, easy to trigger
- Snap — different enough from a clap to tell apart
- Whistle — very distinctive frequency
- Shout — great if you want a loud noise detector
For each sound class, click Record and make your sound 30 or more times. Vary the volume and distance from your microphone.
Train and Test Your Audio AI
Click Train Model and wait for training to complete. Then go to the preview section and try making your sounds. You should see the confidence bars jump to the correct class when you clap, snap, or whistle.
Tip: If the AI keeps confusing two sounds, add more training samples for both classes. 50 recordings per class is better than 30. The more examples you give, the clearer the pattern becomes.
Try to make the AI fail. Clap at a slightly different speed. Clap with one finger against your palm instead of both hands. Does it still recognize it? This is called testing for robustness — real AI engineers do this constantly before releasing a product to the public.
Ideas for What to Build Next
Once your audio model is working, you can export it and connect it to projects in Scratch. Here are some project ideas:
- Virtual Pet: Clap to feed it, snap to play with it, whistle to put it to sleep. Train a three-sound model and build a simple animated pet in Scratch that changes animation based on which sound the AI hears.
- Clap Score Counter: Each time the AI detects a clap, your score goes up by one. How fast can you reach 20 points?
- Silly Sound Quiz: Make a sound and let your friends guess what the AI thinks it is. Whose sounds fool the AI most often?
In the next lesson, you will teach AI to recognize your entire body — and use your poses to control a game.
- AI hears by converting sound into spectrograms and classifying those visual patterns
- Recording background noise is essential so the model knows what to ignore
- Adding more varied sound samples makes an audio model significantly more accurate