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)

Dialogue

result = client.dialogue(
    model="pro",
    lines=[
        {"text": "Welcome to the show!", "voice": "emma", "language": "en"},
        {"text": "Thanks for having me.", "voice": "james", "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.1.0.tar.gz (23.2 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.1.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for leanvox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 39832328522d8bde64f26cc29ca1f6b3a6f2acfae690643f2fda2d8738970a67
MD5 33bd4448a01117d493b03acf8d90bb7d
BLAKE2b-256 494374028a85beaf1ed4894637909798b7a3ba241940870dfe98132c8cadd8c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for leanvox-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: leanvox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1eb17e63edae20bf7a80b3a531c38f3589bc7e4b17c073214cdc03fd1912106d
MD5 9fe2e73abf31a2cf496e59808d2d9152
BLAKE2b-256 8c7cb3f2bc5dacc32f1e99a9638856b87b729892a00097fd480cd78287c3e3ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for leanvox-0.1.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