Go to Map Courses Lab Glossary How it works Troubleshooting Start →
ITEN
← Course 03 · Listening (Lesson 03.02 · 22 minutes · Microphone · First model)

Recognizing a sound.

The doorbell, the whistling kettle and silence. Here you'll teach the phone to recognize three sounds from home, and find out why a model that's always listening is measured in false alarms per hour.

What you learn
  1. How a model listens to sound as it flows by, one second at a time
  2. Why a small network trained from scratch is enough
  3. How background noise helps you train a better model
  4. What false alarms are and how you choose the threshold
You need to know

If you don't remember one of these, the link takes you to the chapter that explains it.

How do you want to follow it
Preparing the scene…
  1. 01 The question

    Three sounds, and a model that tells them apart.

    Pick three sounds from home, for example the doorbell, the whistling kettle and silence. The phone listens, and every half second it says which one it hears. It's a classification01.04 like the one for photos, but the input is the spectrogram03.01 of one second. Silence is a real class, because it's what the microphone hears almost all the time.

    In practice. Choose sounds that repeat the same way every time, like a doorbell or an alarm. A voice that's talking changes all the time and needs many more examples.

01 / 07
(Go deeper)

A few more numbers.


(01)

Speech Commands, the dataset for first steps

In 2018 Pete Warden, from Google, published Speech Commands, a dataset made for small models that are always listening. The second version has more than 105,000 one-second recordings of 35 short words like yes, no, up and down, spoken by more than 2,600 people.

All the clips last one second and use 16,000 samples per second, like the ones in this lesson. There's also a folder of background noises, from the sink to the bicycle, to mix into the examples. It's still the starting point for almost every comparison between keyword spotting models.

  • 105,829one-second clips
  • 35different words
  • 2,618people who said them
(02)

How small a listening network can be

The example model that TensorFlow uses for microcontrollers recognizes two words, yes and no, and weighs about 18 KB. It runs on an Arduino board with 256 KB of memory, with no phone and no operating system. It's TinyML01.01 in the strictest sense.

On the phone there's plenty of space, so you can use a slightly bigger and more accurate network. But the principle stays the same. The mel spectrogram takes the heaviest work off the model, and all the network has left to do is recognize a pattern in a small image.

(03)

A curve for choosing the threshold

Each threshold gives you a pair of numbers, the false alarms per hour and the real sounds missed out of a hundred. If you try every threshold and put the pairs on a chart, you get a curve. The good models sit at the bottom left, because they make few mistakes of both kinds.

The curve lets you compare two models without choosing the threshold first. If one model's curve sits entirely below the other's, the first one is better whatever threshold you use. Then you pick the point on the curve that matches the mistake you can live with.

(Try it on your phone)

Three sounds from home


In the lab you teach the phone to recognize three sounds you choose. You need ten minutes and three sounds that are easy to repeat, for example the doorbell, the kettle and silence.

  1. Open the lab with the button below. It already starts with the Sound input.
  2. Create three classes, two sounds and silence.
  3. Record 20 one-second examples per class, in different rooms and at different distances.
  4. Record 10 seconds of background noise, the kind you usually hear at home.
  5. Press Train. Then in Use press Try it live, let the phone listen for five minutes and count the false alarms.
Open the lab →
(Quiz)

4 questions to close the lesson.

When you have answered them all, the lesson counts as done and its stone on the map turns yellow. Answering is what counts, not the score.


  1. (01)

    Why does the one-second window move every half second and not every second?

  2. (02)

    A model answers twice per second and is wrong once in a thousand. How many false alarms does it make in an hour?

  3. (03)

    Why do you mix background noise into the examples during training?

  4. (04)

    You raise the threshold from 60 to 90 percent. What happens?

To close the lesson, answer the quiz

← Sound becomes an image Back to the map
(Next lesson · 03.03) The word that wakes the phone