supertone on PyPI. Source: supertone-inc/supertone-python.
At a glance
Installation
- pip
- uv
- poetry
Set your API key
The SDK does not auto-read from the environment. Passapi_key explicitly — the convention is to read from SUPERTONE_API_KEY.
Generate speech (sync)
The recommended pattern uses a context manager so the underlying HTTP connection is closed cleanly:Generate speech (async)
Use the_async suffix and async with:
create_speech / create_speech_async, stream_speech / stream_speech_async, list_voices / list_voices_async, and so on.
Stream speech
Streaming returns an iterator (or async iterator) of audio chunks:async for chunk in response.result.aiter_bytes(). Streaming is currently supported on sona_speech_1 only.
Long text auto-chunking
create_speech, create_speech_async, stream_speech, and stream_speech_async automatically split text longer than 300 characters. create_speech runs up to 3 segments in parallel and merges the audio; stream_speech runs segments sequentially and forwards chunks to your iterator.
predict_duration does not auto-chunk — keep that input under 300 characters and sum durations manually for longer scripts.
See Long text for details and tuning.
Common operations
Type-safe enums (optional)
For type safety, the SDK exposes enum constants insupertone.models:
"en", "sona_speech_1") work too — use whichever style you prefer.
Error handling
Errors live insupertone.errors and all extend SupertoneError:
Network errors (DNS failure, broken pipe, etc.) come from
httpx and don’t inherit from SupertoneError.
Configuration
Related
TypeScript SDK
The equivalent SDK for Node and Bun.
Examples
Recipes for common workflows.