Machine Learning Basics

How Speech Recognition Turns Voice Into Text

The steps from sound waves to written words, from microphone capture and acoustic models to language context, and the reasons transcription errors creep in.

On this page
  1. Starting with sound
  2. Step 1: cleaning and summarizing the audio
  3. Step 2: from sound to speech sounds
  4. Step 3: from sounds to words
  5. Step 4: polishing the output
  6. Where errors creep in
  7. Where it is used
  8. Getting better results

Starting with sound

When you speak, your voice makes the air vibrate. A microphone converts those vibrations into an electrical signal, and the device samples that signal many thousands of times per second, storing a long list of numbers. That list is the raw material for speech recognition. At this stage there are no words, only a record of how the air pressure changed over time.

Step 1: cleaning and summarizing the audio

Raw samples are hard to work with, so the audio is usually cut into very short slices, often a few hundredths of a second long. For each slice, the software computes which sound frequencies are present and how strong they are. This turns a wave into something closer to a picture of the sound’s pitch and tone, similar to a spectrogram.

Some systems also reduce background noise or detect when a person starts and stops speaking, so that silence and room noise are not treated as words.

Step 2: from sound to speech sounds

The next job is to work out which basic speech sounds are being produced. Languages are built from units called phonemes, such as the “k” sound at the start of “cat.” A part of the system called the acoustic model estimates, for each slice, how likely each sound is.

This is a pattern recognition task, and it is where machine learning does heavy work. The model is trained on a very large number of recordings paired with correct transcripts, so it learns what different sounds typically look like across speakers. Modern systems commonly use large neural networks for this, rather than hand-written rules. These neural networks learn by adjusting many internal weights to reduce errors on those transcripts.

Some recent designs skip the explicit “sounds” step and learn to map audio directly to letters or word pieces. The principle is the same: learn from many paired examples of audio and text.

Step 3: from sounds to words

Sounds alone are ambiguous. “Recognize speech” and “wreck a nice beach” sound quite similar when said quickly. To choose between candidates, the system uses a language model, which estimates how likely word sequences are. In normal use, “recognize speech” is a far more likely phrase than the alternative, so it wins. The same family of ideas underlies the language models used in text tools, though those are usually much larger.

The system effectively searches through many possible word sequences, combining the acoustic score (“does this sound match?”) with the language score (“is this a sensible sentence?”), and picks the best-scoring one.

Step 4: polishing the output

A raw result is often lowercase text with no punctuation. Further steps may add capital letters, commas and periods, write numbers as digits, and format names or dates. Some systems also separate speakers or add timestamps.

Where errors creep in

Even strong systems make mistakes. Common causes include:

  • Background noise and poor microphones. Overlapping voices, wind or a distant microphone blur the signal.
  • Accents and dialects. If the training recordings contained fewer examples of a particular accent, the system usually performs less well for it. This is a real-world example of the issue known as algorithmic bias.
  • Homophones. Words like “their” and “there” sound identical, so only context can separate them.
  • Rare words and names. Specialist terms, brand names and unusual surnames may be missing from the system’s vocabulary, so it substitutes similar-sounding common words.
  • Fast, mumbled or overlapping speech. Sounds blend together, making boundaries hard to find.
  • Switching languages mid-sentence. Many systems expect one language at a time.

Because the output is a best guess, accuracy numbers quoted for a system depend heavily on the test recordings used. A clean studio recording and a noisy street are very different challenges.

Where it is used

Speech recognition powers dictation on phones, captions on videos, call-center transcripts and voice assistants. Some of these run on the device itself, while others send audio to remote servers for processing. That choice has digital privacy implications, because recordings may be stored or reviewed, and the settings for this are usually found in the product’s privacy controls. Voice-controlled features also rely on speech recognition as the first step before a command can be understood.

Getting better results

A few simple habits often help: use a decent microphone close to your mouth, reduce background noise, speak at a natural pace, and review important transcripts instead of trusting them blindly. For legal, medical or other high-stakes use, a human check is wise, since a single misheard word can change the meaning of a sentence.

The complete guide to machine learning basics

Machine Learning Explained for Beginners
Read the guide

Keep exploring

Guides from other topics

All topics →