inworld-tts Python SDK wraps the Inworld TTS REST API with a clean, Pythonic interface. It handles chunking for long text, retries with exponential backoff, and connection management automatically — reducing typical integrations from 30+ lines of raw HTTP to just a few lines of code.
Quick Start
Speech Synthesis
generate(options)
Synthesize speech and return the complete audio as bytes. Text longer than 2,000 characters is automatically chunked and sent in parallel.
Returns:
bytes — raw audio bytes in the requested encoding.
stream(options)
Stream audio chunks over HTTP as they are generated. Lower time-to-first-audio than generate(). Text must be 2,000 characters or fewer.
generate(), except text must be ≤2,000 characters and the default model is "inworld-tts-1.5-mini".
Yields: bytes — audio chunks as they arrive.
generate_with_timestamps(options)
Same as generate() but also returns word- or character-level timing data. Useful for lip-sync, karaoke, and subtitle alignment.
generate(), plus:
Returns: an object with
audio: bytes and timestamps: TimestampInfo.
stream_with_timestamps(options)
Stream audio chunks, each paired with optional timestamp data. Text must be ≤2,000 characters.
stream(), plus timestamp_type (required). Default model is "inworld-tts-1.5-mini".
Yields: objects with audio: bytes and optional timestamps: TimestampInfo.
play(audio, options)
Play audio from bytes or a file path. Encoding is auto-detected from magic bytes unless overridden.
Voice Management
list_voices(options)
List available voices, optionally filtered by language.
Returns:
list[VoiceInfo]
get_voice(voice)
Get details for a single voice. Works with custom voices in your workspace (cloned or designed voices).
VoiceInfo
clone_voice(options)
Clone a voice from one or more audio recordings — as little as 3 seconds works, and longer samples (up to 15 seconds) improve similarity.
Returns:
CloneVoiceResult — the cloned voice ID is at result.voice.voice_id.
design_voice(options)
Design a new voice from a text description — no audio recording needed.
Returns:
DesignVoiceResult — preview voices at result.preview_voices.
publish_voice(options)
Publish a designed or cloned voice preview to your library so it can be used in generate() and stream().
Returns:
VoiceInfo
migrate_from_elevenlabs(options)
Migrate a voice from ElevenLabs to your Inworld workspace. Fetches the voice’s audio samples directly from ElevenLabs and clones them into Inworld. No ElevenLabs SDK required.
Returns: an object with
eleven_labs_voice_id, eleven_labs_name, and inworld_voice_id.
Configuration
Create a client withInworldTTS():
api_key must be provided directly or through the INWORLD_API_KEY environment variable. If neither is set, a MissingApiKeyError is thrown.Long Text
generate() and generate_with_timestamps() automatically chunk text longer than 2,000 characters and send chunks in parallel (controlled by max_concurrent_requests). The resulting audio is seamlessly concatenated, and timestamp offsets are merged correctly.
stream() and stream_with_timestamps() require text of 2,000 characters or fewer. For longer text with streaming, split the text yourself and call stream() for each segment.
Error Handling
The SDK exports three error classes, all extendingInworldTTSError:
Next Steps
Voice Cloning
Create a personalized voice clone with as little as 3 seconds of audio.
Best Practices
Learn tips and tricks for synthesizing high-quality speech.
API Reference
View the complete TTS API specification.