Python text to speech libraries

Updated Nov 2026

Python text to speech libraries turn a string of text into spoken audio. These libraries give voice assistants, accessibility features, and AI agents a spoken reply.

Popularity

edge-tts has the most installs, while TTS has the most GitHub stars.

LibraryMonthly downloadsStarsLast releaseLicense
edge-tts
7.8M
12.5KOct 2026LGPL-2.1
piper1-gpl
1.3M
6.2KSep 2026GPL-3.0
gTTS
1.2M
2.6KNov 2024MIT
pyttsx3
493.4K
2.5KJul 2025MPL-2.0
kokoro
299.6K
10.0KApr 2025Apache-2.0*
TTS
50.6K
46.2KDec 2023MPL-2.0
RealtimeTTS
28.0K
4.1KMay 2026MIT
parler-tts
2.9K
5.6KJan 2025Apache-2.0*
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year. *Code only; model weights have their own license.

Features compared

LibraryRuns fully offlineClones a voiceStreams audio outputRuns on CPUOutput formats
edge-ttsUnsupportedUnsupportedBuilt-inUndocumentedMP3
piper1-gplBuilt-inUnsupportedBuilt-inBuilt-inWAV
gTTSUnsupportedUnsupportedBuilt-inUnsupportedMP3
pyttsx3Built-inUnsupportedUndocumentedUndocumentedMP3
kokoroBuilt-inUnsupportedBuilt-inBuilt-inWAV
TTSBuilt-inBuilt-inBuilt-inBuilt-inWAV
RealtimeTTSBuilt-inVia pluginVia pluginBuilt-inWAV
parler-ttsBuilt-inUnsupportedBuilt-inBuilt-inWAV
Built-inVia pluginNot supportedNot documented

Libraries and code examples

edge-tts sends text to the online text-to-speech service built into Microsoft Edge and saves the speech as an audio file, with an optional SRT subtitle file. Communicate takes the text and a voice name. From a terminal, the edge-tts command takes the same inputs. Its --list-voices option prints every voice the service offers. The edge-playback command speaks immediately, using the mpv player outside Windows.

Downloads / mo
7.8M
Stars
12.5K
Last release
7.3.1, Oct 2026
License
LGPL-2.1

Strengths

  • No API key. Generates speech with no account or key.
  • 400+ voices. Neural voices in more than 100 languages and accents.
  • Subtitles included. Saves an SRT subtitle file alongside the MP3.

Limitations

  • Online only. Calls Microsoft's service, so it stops when that service is down.
  • No custom SSML. The service rejects custom speech markup.

Quickstart

From the docs
$ pip install edge-tts
import edge_tts

TEXT = "Hello World!"
VOICE = "en-GB-SoniaNeural"
OUTPUT_FILE = "test.mp3"

communicate = edge_tts.Communicate(TEXT, VOICE)
communicate.save_sync(OUTPUT_FILE)

edge-tts examples

From open-source projects on GitHub

Turns podcast text into audio bytes with edge-tts Communicate, saving through a temporary file.

Piper is a local neural text-to-speech engine that uses espeak-ng to turn text into phonemes, the individual sounds of speech, before its voice model generates audio. The Python package installs as piper-tts, voices download with piper.download_voices, and PiperVoice.synthesize_wav saves the audio as a WAV file. Voices are ONNX models, a portable model format, and use_cuda=True runs them on a GPU through onnxruntime-gpu.

Downloads / mo
1.3M
Stars
6.2K
Last release
1.8.0, Sep 2026
License
GPL-3.0
Runs on
ONNX Runtime

Strengths

  • Runs locally on a CPU. A local neural engine that synthesizes speech with no GPU or network connection.
  • Runs on a Raspberry Pi. Works offline on small devices such as a Raspberry Pi 4.
  • Many languages. Voices for 44 languages and regions, including Welsh and Swahili.

Limitations

  • Less natural than big models. Larger neural models sound more human.
  • No voice cloning. New voices must be downloaded or trained.
  • Looking for maintainers. The Open Home Foundation, which runs the project, is seeking new maintainers.

Quickstart

From the docs
$ pip install piper-tts
import wave
from piper import PiperVoice

voice = PiperVoice.load("/path/to/en_US-lessac-medium.onnx")
with wave.open("test.wav", "wb") as wav_file:
    voice.synthesize_wav(
        "Welcome to the world of speech synthesis!",
        wav_file,
    )

piper1-gpl examples

From open-source projects on GitHub

Synthesizes a reference pronunciation offline with a cached PiperVoice and returns the waveform and sample rate.

gTTS sends text to the speech feature of Google Translate and writes the spoken audio to a file, a file-like object, or standard output. gTTS builds the request and save writes the audio. On the command line, gtts-cli takes text and an output file. A sentence tokenizer splits long text so any length can be read while keeping natural intonation. The project uses an undocumented Google feature and is separate from Google Cloud Text-to-Speech.

Downloads / mo
1.2M
Stars
2.6K
Last release
2.5.4, Nov 2024
License
MIT

Strengths

  • About 60 languages. Regional accents come from the tld setting.
  • MP3 to a file or memory. Saves speech to a file or an in-memory buffer.
  • Any length of text. Splits long text into sentences and keeps natural intonation.

Limitations

  • Unofficial. Google doesn't support it, so changes on Google's side can break it.
  • One voice per language. No pitch, voice choice, or SSML.
  • Rate-limited. Heavy use gets HTTP 429 errors from Google.

Quickstart

From the docs
$ pip install gtts
from gtts import gTTS
tts = gTTS('hello', lang='en')
tts.save('hello.mp3')

gTTS examples

From open-source projects on GitHub

Synthesizes a reference pronunciation with gTTS, saving an audio file with the chosen accent and loading it back as a waveform.

Sends a chat message as speech by writing gTTS audio to an in-memory buffer.

pyttsx3 speaks text offline through speech engines installed on the computer: Microsoft's Speech API on Windows, NSSpeechSynthesizer or AVSpeech on macOS, and eSpeak on all three systems. init creates an engine, say queues text, and runAndWait speaks it; save_to_file writes the speech to a file instead. Engine properties set the speaking rate, volume, and voice. Unlike gTTS, the library needs no network connection.

Downloads / mo
493.4K
Stars
2.5K
Last release
2.99, Jul 2025
License
MPL-2.0

Strengths

  • Works offline. Uses voices already installed on the computer.
  • Saves to a file. save_to_file() writes speech to an audio file.
  • Adjustable speed and volume. Set rate and volume as engine properties.

Limitations

  • Sounds like the system voice. Quality depends on the voices Windows, macOS, or Linux provide.
  • Fails on servers without audio. init() raises a RuntimeError on Linux with no audio driver.
  • One request at a time. Calls from several threads wait in line.
  • eSpeak on Linux. Linux needs the espeak-ng system package for speech output and for saving files.

Quickstart

From the README
$ pip install pyttsx3
import pyttsx3

engine = pyttsx3.init()

# For Mac, If you face error related to "pyobjc" when running the `init()` method :
# Install 9.0.1 version of pyobjc : "pip install pyobjc>=9.0.1"

engine.say("I will speak this text")
engine.runAndWait()

pyttsx3 examples

From open-source projects on GitHub

Speaks an assistant's reply by writing it to a WAV file with save_to_file, then playing the file.

kokoro is the inference library for Kokoro, an open-weight text-to-speech model with eighty-two million parameters and Apache-licensed weights. KPipeline takes a language code, such as 'a' for American English, and calling the pipeline on text with a voice name yields audio chunks to play or save. The library converts text to phonemes, the sounds that make up speech, with misaki and falls back to espeak-ng for unknown English words and some other languages. Japanese and Mandarin need the misaki[ja] and misaki[zh] extras.

Downloads / mo
299.6K
Stars
10.0K
Last release
0.9.4, Apr 2025
License
Apache-2.0
Runs on
PyTorch

Strengths

  • Natural for its size. An 82M model that sounds close to much larger ones.
  • Runs on a CPU. No GPU needed.
  • Lighter ONNX version. kokoro-onnx runs the same model with fewer dependencies.

Limitations

  • Preset voices only. No voice cloning.
  • Rushes long lines. Lines past 400 tokens tend to speed up.
  • Needs espeak-ng. Install the espeak-ng system package for some languages.

Quickstart

From the README
$ pip install kokoro
from kokoro import KPipeline
import soundfile as sf
pipeline = KPipeline(lang_code='a')
text = '''
[Kokoro](/kˈOkəɹO/) is an open-weight TTS model with 82 million parameters. Despite its lightweight architecture, it delivers comparable quality to larger models while being significantly faster and more cost-efficient. With Apache-licensed weights, [Kokoro](/kˈOkəɹO/) can be deployed anywhere from production environments to personal projects.
'''
generator = pipeline(text, voice='af_heart')
for i, (gs, ps, audio) in enumerate(generator):
    print(i, gs, ps)
    sf.write(f'{i}.wav', audio, 24000)

kokoro examples

From open-source projects on GitHub

Synthesizes speech offline with a KPipeline per language, sharing one Kokoro model across pipelines.

Turns a chunk of an ebook into a WAV file by joining the audio segments a KPipeline returns.

Coqui TTS is a deep learning toolkit for generating speech, with pretrained models in more than a thousand languages and tools to train or fine-tune new ones. TTS from TTS.api loads a model by name, and tts_to_file writes speech to a WAV file. Passing speaker_wav with a recording clones that speaker's voice. The production model is XTTS, which supports sixteen languages and streams its output.

Downloads / mo
50.6K
Stars
46.2K
Last release
0.22.0, Dec 2023
License
MPL-2.0
Runs on
PyTorch

Strengths

  • Clones voices. Copies a speaker's voice from a short audio clip.
  • Many languages. XTTS v2 speaks 17 languages naturally, and MMS models reach about 1,100.
  • Train custom voices. Includes tools to train and fine-tune models.

Limitations

  • GPU for real-time speed. The neural models run on a CPU, more slowly than on a GPU.
  • XTTS isn't for commercial use. The XTTS model license forbids commercial use.

Quickstart

From the docs
$ pip install tts
from TTS.api import TTS
api = TTS(model_name="tts_models/eng/fairseq/vits").to("cuda")
api.tts_to_file("This is a test.", file_path="output.wav")

# TTS with on the fly voice conversion
api = TTS("tts_models/deu/fairseq/vits")
api.tts_with_vc_to_file(
    "Wie sage ich auf Italienisch, dass ich dich liebe?",
    speaker_wav="target/speaker.wav",
    file_path="ouptut.wav"
)

TTS examples

From open-source projects on GitHub

Writes a chunk of an ebook to a WAV file with tts_to_file, passing a speaker for multi-speaker models.

Writes speech to a WAV file with Coqui TTS, cloning a reference voice through tts_with_vc_to_file when configured.

RealtimeTTS turns strings, generators, and streaming LLM output into speech with low latency. TextToAudioStream wraps an engine, such as SystemEngine for the voices built into the operating system, and feed accepts text, including an iterator whose text is still arriving while audio plays. The same interface drives cloud APIs, local neural models, and voice-cloning engines, and switches to another engine when one fails. Output plays locally, streams to another process, or saves as WAV.

Downloads / mo
28.0K
Stars
4.1K
Last release
0.7.3, May 2026
License
MIT

Strengths

  • Speaks while text streams in. Plays audio while an LLM is still writing.
  • One API for many engines. System voices, cloud APIs, and local models work the same way.
  • Automatic fallback. Switches to another engine if one fails.

Limitations

  • Install each engine separately. Every engine is its own extra package.
  • Needs PortAudio on Linux and macOS. Install PortAudio before the audio engines.
  • Recommended engine needs NVIDIA. The recommended engine runs on NVIDIA GPUs.

Quickstart

From the README
$ pip install realtimetts
from RealtimeTTS import TextToAudioStream, SystemEngine


if __name__ == "__main__":
    stream = TextToAudioStream(SystemEngine())
    stream.feed("Hello from RealtimeTTS.")
    stream.play()

RealtimeTTS examples

From open-source projects on GitHub

Speaks an assistant's reply while it streams, feeding each chunk to RealtimeTTS and starting playback at the first delimiter.

Speaks a chat message by feeding it to a RealtimeTTS stream and playing it in the background.

Parler-TTS generates speech in a voice described in plain text, such as the speaker's gender, pitch, pace, and recording quality. The model loads through Hugging Face Transformers and takes two inputs: the description and the text to speak. Thirty-four named speakers keep the same voice across runs when the description mentions that speaker's name. Datasets, training code, and weights are all public under permissive licenses.

Downloads / mo
2.9K
Stars
5.6K
Last release
0.2.3, Jan 2025
License
Apache-2.0
Runs on
PyTorch

Strengths

  • Describe the voice in words. Text like "a calm female voice, slow pace" sets the voice.
  • Consistent named speakers. 34 named speakers keep the same voice across runs.
  • Few lines of code. Runs through Hugging Face Transformers.

Limitations

  • GPU recommended. The README example runs on a CUDA GPU when one is present and falls back to the CPU.
  • Sounds like an audiobook. Trained on read speech, so casual or emotional styles are weak.

Quickstart

From the README
$ pip install parler-tts
import torch
from parler_tts import ParlerTTSForConditionalGeneration
from transformers import AutoTokenizer
import soundfile as sf

device = "cuda:0" if torch.cuda.is_available() else "cpu"

model = ParlerTTSForConditionalGeneration.from_pretrained("parler-tts/parler-tts-mini-v1").to(device)
tokenizer = AutoTokenizer.from_pretrained("parler-tts/parler-tts-mini-v1")

prompt = "Hey, how are you doing today?"
description = "A female speaker delivers a slightly expressive and animated speech with a moderate speed and pitch. The recording is of very high quality, with the speaker's voice sounding clear and very close up."

input_ids = tokenizer(description, return_tensors="pt").input_ids.to(device)
prompt_input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)

generation = model.generate(input_ids=input_ids, prompt_input_ids=prompt_input_ids)
audio_arr = generation.cpu().numpy().squeeze()
sf.write("parler_tts_out.wav", audio_arr, model.config.sampling_rate)

parler-tts examples

From open-source projects on GitHub

Turns a chatbot reply into a WAV file with Parler-TTS, describing the voice in a text prompt.

Serves an OpenAI-style speech endpoint that generates audio with Parler-TTS from text and a voice description.

FAQ

It depends on the job. pyttsx3 speaks offline with the computer's own voices, kokoro gives natural neural voices on a CPU, gTTS covers many languages online, and Coqui TTS clones voices. edge-tts uses online voices and has 7.8M downloads a month.

pyttsx3, Piper, kokoro, Coqui TTS, RealtimeTTS, and parler-tts all run without an internet connection. pyttsx3 uses the voices built into Windows, macOS, or Linux, while the others run neural models on the machine. edge-tts and gTTS need the internet. See Capabilities.

Install a library with pip, pass it the text, and save or play the audio. With gTTS, gTTS(text, lang='en').save(path) writes an MP3 file. With pyttsx3, say() queues the text and runAndWait() speaks it aloud with no internet.

Coqui TTS clones a voice from a short audio clip, and RealtimeTTS clones voices through its optional engines. The other six libraries use preset or system voices only. See Capabilities.

Yes. edge-tts sends text to Microsoft Edge's online speech service, so it stops working without a connection or when that service is down. For offline speech, Piper and kokoro run on the machine itself.

kokoro is a Python library that runs Kokoro, a small open-weight text-to-speech model, on the machine itself. It works offline on a CPU with no GPU, and it sounds close to much larger models.

For coding agents

Found your text to speech library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official