Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
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.
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.
def generate_audio(self, text: str, voice: str, model: str, voice2: str = None) -> bytes:
"""Generate audio using Edge TTS."""
import nest_asyncio
import asyncio
# Apply nest_asyncio to allow nested event loops nest_asyncio.apply()
async def _generate():
communicate = edge_tts.Communicate(text, voice)
# Create a temporary file with proper context management with tempfile.NamedTemporaryFile(suffix='.mp3', delete=False) as tmp_file:
temp_path = tmp_file.name
try:
# Save audio to temporary file await communicate.save(temp_path)
# Read the audio data with open(temp_path, 'rb') as f:
return f.read()
finally:
# Clean up temporary file if os.path.exists(temp_path):
os.remove(temp_path)
# Use nest_asyncio to handle nested event loops loop = asyncio.get_event_loop()
return loop.run_until_complete(_generate())
piper1-gpl
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.
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,
)
def synthesize_piper(text, lang, voice):
"""Synthesize with Piper (offline). Returns ``(waveform, sample_rate)``."""
piper = _import("piper", "piper")
if voice not in _piper_voices:
model, config = _piper_voice_files(voice)
_piper_voices[voice] = piper.PiperVoice.load(model, config)
engine = _piper_voices[voice]
chunks = list(engine.synthesize(text))
if not chunks:
raise RuntimeError(f"Piper produced no audio for {text!r}")
waveform = np.concatenate([c.audio_float_array for c in chunks]).astype(np.float32)
return waveform, chunks[0].sample_rate
gTTS
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.
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.
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()
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.
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)
def synthesize_kokoro(text, lang, voice):
"""Synthesize with Kokoro-82M (offline). Returns ``(waveform, sample_rate)``."""
kokoro = _import("kokoro", "kokoro")
lang_code, _ = _kokoro_language(lang)
if lang_code not in _kokoro_pipelines:
# Share the 82M model between per-language pipelines. model = next((p.model for p in _kokoro_pipelines.values()), True)
_kokoro_pipelines[lang_code] = kokoro.KPipeline(lang_code=lang_code, repo_id=KOKORO_REPO, model=model)
pipeline = _kokoro_pipelines[lang_code]
parts = [r.audio.detach().cpu().numpy() for r in pipeline(text, voice=voice) if r.audio is not None]
if not parts:
raise RuntimeError(f"Kokoro produced no audio for {text!r}")
return np.concatenate(parts).astype(np.float32), KOKORO_SAMPLE_RATE
def proccess_text(self, text, wave_file_name):
audio_segments = []
for gs, ps, audio in self.pipeline(text, voice=self.speaker, speed=self.speed, split_pattern=r'\n\n\n'):
audio_segments.append(audio)
final_audio = np.concatenate(audio_segments)
sf.write(wave_file_name, final_audio, 24000)
if os.path.exists(wave_file_name):
return True
return False
TTS
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.
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 conversionapi = 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"
)
def proccess_text(self, text, wave_file_name):
if self.model_name == "tts_models/en/vctk/vits":
self.minratio = 0
# assume we're using a multi-speaker model if self.debug:
print(text)
with open("debugout.txt", "a") as file: file.write(f"{text}\n")
self.tts.tts_to_file(
text=text,
speaker=self.config['speaker'],
file_path=wave_file_name,
)
else:
if self.debug:
print(text)
with open("debugout.txt", "a") as file: file.write(f"{text}\n")
self.tts.tts_to_file(
text=text, file_path=wave_file_name
)
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.
async def new_output(self):
while True:
output = await old_output()
# if output == {"role": "assistant", "type": "message", "start": True}: # return {"role": "assistant", "type": "audio", "format": "bytes.wav", "start": True} if isinstance(output, bytes):
return output
await asyncio.sleep(0)
delimiters = ".?!;,\n…)]}"
if output["type"] == "message" and len(output.get("content", "")) > 0:
self.tts.feed(output.get("content"))
if not self.tts.is_playing() and any([c in delimiters for c in output.get("content")]): # Start playing once the first delimiter is encountered.
self.tts.play_async(on_audio_chunk=self.on_tts_chunk, muted=not self.play_audio, sentence_fragment_delimiters=delimiters, minimum_sentence_length=9)
return {"role": "assistant", "type": "audio", "format": "bytes.wav", "start": True}
if output == {"role": "assistant", "type": "message", "end": True}:
if not self.tts.is_playing(): # We put this here in case it never outputs a delimiter and never triggers play_async^
self.tts.play_async(on_audio_chunk=self.on_tts_chunk, muted=not self.play_audio, sentence_fragment_delimiters=delimiters, minimum_sentence_length=9)
return {"role": "assistant", "type": "audio", "format": "bytes.wav", "start": True}
return {"role": "assistant", "type": "audio", "format": "bytes.wav", "end": True}
def play(self, message):
if not self.enabled:
return
# If the message is only whitespace, don't attempt to play it if not message.strip():
return
self.signals.sio_queue.put(("current_message", message))
self.stream.feed(message)
self.stream.play_async()
parler-tts
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.
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)
def text_to_speech(text, filename="output_audio.wav"):
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model = ParlerTTSForConditionalGeneration.from_pretrained(
"parler-tts/parler_tts_mini_v0.1"
).to(device)
tokenizer = AutoTokenizer.from_pretrained("parler-tts/parler_tts_mini_v0.1")
# ... description = "Utilize a male voice with a low pitch and an Indian English accent for the chatbot. The speech should be fast yet clear, ensuring each word is distinctly articulated in a crisp and confined audio environment."
input_ids = tokenizer(description, return_tensors="pt").input_ids.to(device)
prompt_input_ids = tokenizer(text, 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(filename, audio_arr, model.config.sampling_rate)
return filename
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.
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.