Codiqo

Understanding AI · lesson 36 of 60 · about 5 minutes

Sound and Speech

How does AI understand what you say? Follow sound from a wave of air to numbers to words.

What you'll learn

  • Explain how sound is recorded as numbers
  • Work out how many numbers a recording holds
  • Describe how speech AI turns sound into words

Sound as numbers

Sound is air wobbling back and forth. A microphone measures that wobble thousands of times a second; each measurement is a number called a sample. CD-quality audio takes 44100 samples every second.

How many numbers in 3 seconds of CD-quality sound?

samples_per_second = 44100
seconds = 3
print(samples_per_second * seconds)

Output

132300

From sound to words

Speech AI usually turns the samples into a picture of which pitches are loud at each moment, then uses a neural network to find the patterns of speech sounds in it, much like finding edges and shapes in a photo. Finally it works out the most likely words, using what it knows about language: wreck a nice beach sounds almost exactly like recognise speech.

Tip

More samples per second capture sound more exactly, but mean more numbers to process.

Now try it yourself

This lesson is free in Codiqo, with 6 questions on what you just read. You can only learn to code by writing code, so it ends with a short program you write yourself, which we run and check straight away.