[HAND CLAPPING]
[GUITAR STRUMMING]
[CHIRPING]
PRIYANKA VERGADIA: Want to know how
I built this without any code?
Stay tuned.
[MUSIC PLAYING]
Welcome to "AI Adventures," where
we explore the art, science, and tools of machine learning.
And today, I'm going to show you how to train a sound classifier
with absolutely no code.
We are going to use Teachable Machines for this.
Teachable Machines allows us to train a machine learning
model right in the browser.
We can train it on images, audio,
and poses, with more to come.
We gather the data, train the model,
and export it to use it in our own projects.
That's exactly what we will do today.
We will create an audio project, record some samples
of background noise.
You might see a browser notification
to allow using the microphone, and I have already
done that here.
So once the audio is recorded, we
extract these samples, which are one second each.
For background noise, it requires 20 samples.
Then take a few samples of--
[HAND CLAPPING]
Clapping sound, and we label them as clap.
And here, it needs eight samples of one second each.
Let's record a few samples for guitar sound.
[GUITAR STRUMMING]
Now for our last label, let's record a few bird
sound samples.
I have this bird that I got from trip to Mexico,
and it makes this beautiful bird chirp sound.
[CHIRPING]
Once our labels are recorded, all we need to do
is to train the model.
Since this is browser-based training,
make sure to not close the window.
While the model is training, you might
be wondering what's happening under the hood.
Well, there is a lot happening.
But to give you a quick sense, these models
use a technique called transfer learning.
There's a pre-trained neural network,
and when you create your own classes or labels,
the properties of these classes become the last layer
of that neural network.
Specially, both the image and pause models
learn off of the pre-trained MobileNet models,
and the sound model is built on speech command recognizer.
If you are curious to dive deeper,
there's a blog linked below just for you.
And it is trained.
We can test it out right here.
Let me make the bird sound.
[CHIRPING]
And it rightly identifies it as our bird label.
If I clap--
[HAND CLAPPING]
It identifies it as clap.
And if I play guitar--
[GUITAR STRUMMING]
It identifies that too.
Cool, right?
Now that we are happy with our model,
we can upload it to be hosted or download
it to use directly in our app.
On uploading, we get a link to our model
that we can copy and use in our apps.
Let's test it right here in p5.js.
Replace our model URL, and if we run it,
it shows the label text.
Now, to make the output a little bit more interesting,
let's add some fun emojis for each label.
And let's test it out again.
We play some guitar, we play the bird chirp, and we clap.
Now this is cool, but I wanted to use
this as a web application.
So I downloaded this HTML and JavaScript
from p5.js web editor and decided
to host a simple node.js web app on Cloud Run.
Pointed the index.js file to call
the index.js HTML that was downloaded from p5.js,
and that's it.
And here is the web app that can now predict the sounds
that we trained it on.
If you are interested in the code,
I have linked the GitHub repository below.
And that's how you do it.
We just trained a sound classification model
with literally no code, applied minor changes
to make our predictions fun, and then finally deployed it
on Cloud Run.
If you're feeling adventurous and would
like to get deeper into the sound classification
techniques, I've included a link to the tutorial below.
Thanks for watching, and I look forward
to seeing you next time with another tool in the AI toolkit.
Until then.
[CHIRPING]