Skip to main content

Official Python SDK for the Leanvox TTS API

Project description

Leanvox Python SDK

Official Python SDK for the Leanvox TTS API.

Install

pip install leanvox

Quick Start

from leanvox import Leanvox

client = Leanvox(api_key="lv_live_...")
# or set LEANVOX_API_KEY env var

# Generate speech
result = client.generate(text="Hello from Leanvox!", model="standard")
print(result.audio_url)

# Download audio
result.save("hello.mp3")

Streaming

with client.stream(text="Long narration...", voice="af_heart") as stream:
    with open("output.mp3", "wb") as f:
        for chunk in stream:
            f.write(chunk)

Max (Instruction-Based Voice)

# Describe any voice in natural language
result = client.generate(
    text="Welcome to our podcast!",
    model="max",
    voice_instructions="A warm, confident female narrator with a slight British accent",
)
print(result.generated_voice_id)  # Reuse this ID for consistent voice

Dialogue

result = client.dialogue(
    model="pro",
    lines=[
        {"text": "Welcome to the show!", "voice": "narrator_warm_male", "language": "en"},
        {"text": "Thanks for having me.", "voice": "assistant_pro_female", "language": "en"},
    ],
    gap_ms=500,
)

Async

from leanvox import AsyncLeanvox

async with AsyncLeanvox() as client:
    result = await client.generate(text="Hello async!")

Voice Management

# List voices
voices = client.voices.list(model="pro")

# Clone a voice ($3 to unlock)
voice = client.voices.clone(name="My Voice", audio=open("ref.wav", "rb"))
client.voices.unlock(voice.voice_id)

# Design a voice ($1)
voice = client.voices.design(name="Narrator", prompt="Deep warm male voice")

Error Handling

from leanvox import LeanvoxError, InsufficientBalanceError, RateLimitError

try:
    result = client.generate(text="Hello")
except InsufficientBalanceError as e:
    print(f"Need credits: balance={e.balance_cents}")
except RateLimitError as e:
    print(f"Rate limited, retry after: {e.retry_after}")
except LeanvoxError as e:
    print(f"API error: {e.code} - {e.message}")

Auth Priority

  1. Constructor param: Leanvox(api_key="...")
  2. Environment variable: LEANVOX_API_KEY
  3. Config file: ~/.lvox/config.toml

Requirements

  • Python 3.9+
  • httpx

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leanvox-0.5.0.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leanvox-0.5.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file leanvox-0.5.0.tar.gz.

File metadata

  • Download URL: leanvox-0.5.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for leanvox-0.5.0.tar.gz
Algorithm Hash digest
SHA256 55e4bb3b3b1e4e7d011d14c47e40b740ca56714bab8d9a43b0ac88956b5462e9
MD5 e770b0875e5c02624b07e09db29354c4
BLAKE2b-256 ef5e942eba49ea654aed214a0008530595b8f4f1eeaace093b512db8e47f3d1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for leanvox-0.5.0.tar.gz:

Publisher: publish-pypi.yml on leanvox/leanvox-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file leanvox-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: leanvox-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for leanvox-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5e5d2712ba3aa8cf254bdc6a9371bdfd2754ca142cb33723ec27b452cb4e01e
MD5 e5be54e73ce8c85dc858521b3ddd02b6
BLAKE2b-256 f92b1627c85f96e7de8e72480a0d4793c0f1923c4cac2925b9650d6cb4194572

See more details on using hashes here.

Provenance

The following attestation bundles were made for leanvox-0.5.0-py3-none-any.whl:

Publisher: publish-pypi.yml on leanvox/leanvox-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page