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
- Constructor param:
Leanvox(api_key="...") - Environment variable:
LEANVOX_API_KEY - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leanvox-0.3.0.tar.gz.
File metadata
- Download URL: leanvox-0.3.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e5703173f683f6043006dfd7d6af2c819dfe0f842e27ec9cd93d2742fa17eaa
|
|
| MD5 |
5db6f396b023a359c9442a674688cb5a
|
|
| BLAKE2b-256 |
8234f9463ad13934ddba27998b446adbd67f85ad7c07698804c91469e5c04d46
|
Provenance
The following attestation bundles were made for leanvox-0.3.0.tar.gz:
Publisher:
publish-pypi.yml on leanvox/leanvox-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leanvox-0.3.0.tar.gz -
Subject digest:
8e5703173f683f6043006dfd7d6af2c819dfe0f842e27ec9cd93d2742fa17eaa - Sigstore transparency entry: 1010494613
- Sigstore integration time:
-
Permalink:
leanvox/leanvox-python@7729a1be4d34b5ee11f0c43cc3096f4bca1eed73 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/leanvox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7729a1be4d34b5ee11f0c43cc3096f4bca1eed73 -
Trigger Event:
push
-
Statement type:
File details
Details for the file leanvox-0.3.0-py3-none-any.whl.
File metadata
- Download URL: leanvox-0.3.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83b6f675824b6a8ac6259fb8449e713d70c922942f905deb6820983161908fd7
|
|
| MD5 |
1c5e69e01326a04d9ed2ab61d902222e
|
|
| BLAKE2b-256 |
2931522a8a4324488e0a617567417db75c9deb01672e1ea2bd6089ff711b464c
|
Provenance
The following attestation bundles were made for leanvox-0.3.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on leanvox/leanvox-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leanvox-0.3.0-py3-none-any.whl -
Subject digest:
83b6f675824b6a8ac6259fb8449e713d70c922942f905deb6820983161908fd7 - Sigstore transparency entry: 1010494668
- Sigstore integration time:
-
Permalink:
leanvox/leanvox-python@7729a1be4d34b5ee11f0c43cc3096f4bca1eed73 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/leanvox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7729a1be4d34b5ee11f0c43cc3096f4bca1eed73 -
Trigger Event:
push
-
Statement type: