How text to speech works: from written words to a spoken voice

Text to speech works in two stages. First the software works out what to say: it expands numbers and abbreviations, turns spelling into a sequence of speech sounds and decides the rhythm and intonation. Then it generates audio for those sounds, today usually with a neural network trained on recordings of a real voice. In a web page, the text to speech tool hands both stages to a speech engine supplied by your device or browser, which is why the voices differ from one computer to the next.

The two halves of a TTS system

Speech synthesisers are usually described as a front end and a back end. The front end is linguistics: it reads the text and produces a description of how it should sound, as phonemes (individual speech sounds) plus prosody (pitch, timing and stress). The back end, often just called the synthesiser, turns that description into a waveform you can hear. Early systems were impressive demonstrations; in 1961 researchers at Bell Labs had a computer sing "Daisy Bell". Modern voices are far more natural, but the same split still describes how they work.

Turning text into sounds

Written text is full of things that are not words. The first job is text normalisation, which expands them into what a person would say:

  • Numbers: 1984 may be a year (nineteen eighty-four) or a quantity (one thousand nine hundred and eighty-four), and ยฃ5 must become five pounds.
  • Abbreviations: Dr. can be doctor or drive, and St. can be saint or street.
  • Homographs: words spelled alike but said differently, such as read (present or past), lead (to guide, or the metal) and wind.

Next comes grapheme-to-phoneme conversion: looking words up in a pronunciation dictionary and applying rules for words that are not in it, such as new names. Finally the system plans prosody: a rising pitch for many questions, pauses at commas and full stops, and stress on the right syllables. Most of the odd mistakes you hear from a synthetic voice come from this stage, not from the voice itself.

Turning sounds into audio

Three broad approaches have been used. Formant synthesis generates sound from rules modelling the vocal tract; it sounds robotic but stays clear even at high speeds. Concatenative synthesis stitches together small pieces of recorded human speech; it sounds natural when the right pieces exist and glitchy at the joins when they do not. Neural synthesis, which arrived with DeepMind's WaveNet in 2016 and systems like Google's Tacotron 2 in 2018, learns to generate audio directly from examples. Neural voices are the reason today's best voices can be hard to tell from a person.

Text to speech in a browser

Browsers expose speech through the Web Speech API. A page creates an utterance containing the text, sets its rate, pitch and volume, picks a voice from the list the browser reports, and asks the browser to speak it. My tool does exactly that, with speed from 0.5 to 2 times, pitch from 0 to 2 and volume from 0 to 1, plus pause, resume and stop. The voice list comes from your operating system and browser, so Windows, macOS, Android and iOS each offer different voices and languages, and some browsers fill the list a moment after the page loads. There is no download button because the API plays the audio without giving the page a file; to keep a recording you need a separate recording tool, such as the voice recorder for your own voice.

Where your text goes

The page itself never uploads your text, but the voice you choose matters. The API marks each voice as local or remote. Voices built into your operating system run on your device and work offline. Some browsers add network voices: in Chrome the voices named Google are typically generated online, and in Edge the voices labelled Online (Natural) are generated by Microsoft's cloud service. With those, your text is sent to that provider to be spoken. If privacy matters, pick a system voice, or test it: a voice that still speaks with your connection switched off is running locally. The Pikkit tool marks remote voices online voice in its list and picks an on-device voice by default.

Getting more natural results

  • Punctuate for the ear. Commas and full stops create pauses, so break up long sentences.
  • Spell out what could be misread. Write 5 to 7 pm rather than 5-7pm, and expand unusual abbreviations.
  • Simplify the text. Sentences that are hard to read are harder to follow by ear; the readability checker flags the long ones.
  • Try several voices and a slightly slower speed for unfamiliar material.
  • Proofread by listening. Hearing your writing read aloud exposes missing and doubled words that the eye skips; the duplicate word finder catches the doubles directly.

Text to speech pairs well with other tools: How OCR works, and why scans read better than photos explains how text is pulled out of photos and scans so it can be read aloud, and Sample rate and bit depth explained: what 44.1 kHz and 16-bit actually mean covers the audio side if you record the result.

Sources and further reading

The claims in this guide rest on these references, which were checked when the guide was last updated. Spotted an error? The contact page says how to report it.

  1. Speech synthesis โ€” Wikipedia
  2. Web Speech API โ€” MDN Web Docs
  3. SpeechSynthesisVoice.localService โ€” MDN Web Docs (local vs remote voices)

Try the tool

Frequently asked questions

How does text to speech work?

It first converts text into speech sounds with timing and intonation, then generates audio for those sounds, usually with a neural network today.

Why do the voices differ between devices?

Browsers use the speech voices provided by the operating system and browser, so each platform offers its own set.

Is my text sent anywhere?

With voices built into your system, no. Network voices, such as Chrome's Google voices or Edge's Online voices, send the text to that provider.

Can I download the speech as an audio file?

Not from the browser's speech API, which plays audio without exposing a file. You need a recording tool or a service that renders audio files.