DEV Community

Leanvox
Leanvox

Posted on

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

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!")
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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,
)
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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"
)
Enter fullscreen mode Exit fullscreen mode

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

What Details
Install pip install leanvox
Lines to first audio 3
Dependencies 0 (stdlib only)
Python versions 3.8+
Async support Yes
Streaming Yes

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
Enter fullscreen mode Exit fullscreen mode
from leanvox import Leanvox
client = Leanvox()
result = client.generate(text="Let's build something amazing.")
print(result.audio_url)
Enter fullscreen mode Exit fullscreen mode

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

Website
Get your API key


Built with 🔥 by the Leanvox team

Top comments (0)