← All posts
· 5 min read

Introducing the LeanVox Python SDK: Text-to-Speech in 3 Lines

The official LeanVox Python SDK is here. Generate speech, stream audio, clone voices, and create multi-speaker dialogue — all in a few lines of Python.

pythonsdkttsdeveloper-toolsopen-source

What if adding voice to your Python app was as easy as pip install and three lines of code?

Today it is.

from leanvox import Leanvox
client = Leanvox()
result = client.generate(text="Hello from LeanVox!")

That's not a simplified example. That's the actual code. Install, authenticate, generate — done.

We just shipped the official LeanVox Python SDK, and we built it with one goal: make text-to-speech so simple that the docs feel unnecessary.

Why We Built This

We've all been there. You find a TTS API, get excited, then spend 45 minutes wrestling with authentication headers, base64 decoding, callback URLs, and XML payloads from 2009.

We think generating speech from text should be as easy as printing "hello world." So that's what we made.

What You Get

Generate speech instantly

result = client.generate(
    text="Welcome to the future of voice.",
    model="pro",
    voice="af_heart",
    speed=1.1
)
print(result.audio_url)  # CDN URL, ready to use

Stream audio in real-time

No buffering. No waiting for the full file. Audio starts playing as it generates.

with client.stream(text="This is streaming...") as audio:
    for chunk in audio:
        play(chunk)

Create multi-speaker dialogue in one call

Podcasts, conversations, character dialogue — one API call.

episode = client.dialogue(
    model="pro",
    lines=[
        {"text": "Welcome to the show!", "voice": "emma"},
        {"text": "Great to be here.", "voice": "james"},
    ],
    gap_ms=400,
)

Clone your voice

Upload a 30-second sample. Get a voice that sounds like you.

voice = client.voices.clone(name="My Voice", audio=open("sample.wav", "rb"))
client.voices.unlock(voice.voice_id)
result = client.generate(text="This is my voice!", voice=voice.voice_id)

Design a voice from a text prompt

No samples? No problem. Describe the voice you want.

narrator = client.voices.design(
    name="Epic Narrator",
    prompt="Deep, warm male voice with gravitas"
)

Under the Hood

This isn't a quick hack. The SDK is production-grade:

  • Typed responses — full type hints, IDE autocompletion works everywhere
  • Sync + Asyncclient.generate() or await client.agenerate()
  • Auto-retry — exponential backoff on 5xx errors, respects rate limits
  • Zero dependencies — just Python's stdlib HTTP + JSON
  • Streaming first-class — context managers, not callbacks

The Numbers

WhatDetails
Installpip install leanvox
Lines to first audio3
Dependencies0 (stdlib only)
Python versions3.8+
Async supportYes
StreamingYes

What's Next

This is just the beginning. On the roadmap:

  • Node.js/TypeScript SDK — coming soon
  • Go SDK — for the systems crowd
  • Interactive playground — try before you code

Get Started

pip install leanvox
from leanvox import Leanvox
client = Leanvox()
result = client.generate(text="Let's build something amazing.")
print(result.audio_url)

That's it. Three lines. Now go build something that talks.

GitHub · PyPI · Get your API key


Try LeanVox free

$0.50 in free credits. No credit card required. Start generating speech in 30 seconds.

Get started free →