Text to speech: how neural networks turn text into a natural voice

Updated

Text-to-speech (TTS) systems use deep neural networks to analyze text and generate audio waveforms. The process involves linguistic analysis to understand pronunciation and prosody, then converting text into a spectrogram, which a vocoder turns into audio. Modern architectures like WaveNet and Tacotron 2 produce speech nearly indistinguishable from human recordings.

From robotic voices to neural speech synthesis

Text-to-speech technology converts written text into spoken audio. Early systems used concatenative synthesis, which recombined recorded speech fragments, or parametric synthesis, which used signal processing. These methods often produced robotic-sounding voices, as described in IBM's overview of text-to-speech.

The introduction of deep neural networks transformed TTS. Models now learn directly from audio data, capturing nuances of pitch, tone, and rhythm. This shift has made synthetic speech much more natural. According to IBM's explanation, deep learning techniques allow speech synthesis models to process more data and better understand the relationship between words and their acoustic features.

Neural TTS is now used in virtual assistants, audiobooks, and accessibility tools. The technology continues to improve with larger datasets and more sophisticated architectures.

The two-stage pipeline: linguistic analysis and waveform generation

A neural TTS system first performs linguistic analysis on the input text. It expands abbreviations, determines pronunciation, and models prosody, which is the stress, intonation, and timing of speech. This analysis is typically done by a deep neural network trained on paired text and audio data, as noted by IBM.

The analyzed text is then transformed into a time-aligned acoustic representation, such as a mel spectrogram. A mel spectrogram maps sound frequencies over time and captures the detailed characteristics of speech. The Tacotron 2 paper describes how a recurrent sequence-to-sequence feature prediction network maps character embeddings to mel-scale spectrograms.

Finally, a vocoder network converts the spectrogram into raw audio waveforms. WaveNet, introduced by DeepMind, is a generative model that produces each audio sample one at a time, conditioned on all previous samples. The WaveNet paper explains that this autoregressive approach yields highly natural speech and can be efficiently trained on data with tens of thousands of samples per second.

Tacotron 2 combines a sequence-to-sequence model that predicts mel spectrograms from text with a modified WaveNet vocoder. This two-stage architecture achieved a mean opinion score (MOS) of 4.53, close to the 4.58 of professionally recorded speech, as stated in the Tacotron 2 paper.

Key architectures: WaveNet and Tacotron 2

WaveNet, described in a paper by researchers at DeepMind, directly models raw audio waveforms. It uses dilated convolutional layers to capture long-range dependencies in the audio signal. The DeepMind blog reports that when applied to TTS, WaveNet was rated as significantly more natural than both concatenative and parametric systems for English and Mandarin, reducing the gap with human performance by over 50%.

Tacotron 2 introduced an end-to-end neural architecture that generates speech directly from characters. Its recurrent encoder-decoder network predicts mel spectrograms, which are then converted to audio by a WaveNet vocoder. This design simplifies the pipeline and improves quality, as detailed in the Tacotron 2 paper.

Several other neural TTS models are available through libraries like Hugging Face Transformers, including SpeechT5, VITS, and Bark. These models support multiple languages and speakers, and some can generate non-verbal sounds like laughter, as shown in the Hugging Face text-to-speech task guide.

Customizing speech with SSML and voice selection

Speech Synthesis Markup Language (SSML) is an XML-based standard that allows fine-grained control over synthesized speech. Users can adjust pitch, speaking rate, volume, and add pauses. SSML also enables correct pronunciation of acronyms and numbers. Microsoft's text-to-speech overview explains that SSML can be used to define custom lexicons or switch to different speaking styles.

Cloud TTS services offer a wide selection of voices differing by language, gender, and accent. For example, Google Cloud Text-to-Speech provides voices for many languages and allows selection of specific voice names, as described in their basics documentation.

Microsoft Azure Speech service includes standard neural voices and custom voice options. Custom voice enables creating a unique brand voice through professional fine-tuning. Both services support real-time synthesis and asynchronous synthesis for long audio, according to Microsoft's documentation.

Mean Opinion Score (MOS) of Tacotron 2 compared to human speechTacotron 2: 4.53 MOS; Human speech: 4.58 MOSMean Opinion Score (MOS) of Tacotron 2compared to human speechTacotron 24.53 MOSHuman speech4.58 MOS
Figures from arXiv
Comparison of WaveNet and Tacotron 2 architectures
ArchitectureKey innovationOutput type
WaveNetAutoregressive generation of raw audio samplesRaw waveform
Tacotron 2Sequence-to-sequence prediction of mel spectrogramsMel spectrogram + WaveNet vocoder

Frequently asked questions

What is text-to-speech?

Text-to-speech (TTS) is technology that converts written text into spoken audio. Modern TTS uses deep neural networks to produce natural-sounding speech, as explained by IBM.

How does neural TTS differ from older methods?

Older methods like concatenative synthesis recombined recorded fragments, while parametric synthesis used signal processing. Neural TTS learns directly from data, producing more natural and flexible speech, according to IBM and the DeepMind blog.

What is SSML?

Speech Synthesis Markup Language (SSML) is an XML-based language that allows control over pitch, rate, volume, and pauses in synthesized speech. It also helps with correct pronunciation, as described by Microsoft.

Can TTS clone a specific voice?

Yes, some services offer custom voice creation. Microsoft Azure provides professional voice fine-tuning to create a unique brand voice, as noted in their documentation.

What are the best neural TTS models?

WaveNet and Tacotron 2 are landmark models. Many other models like SpeechT5, VITS, and Bark are available through libraries like Hugging Face Transformers, as shown in their task guide.