Skip to main content

lexigram-multimedia-tts

Text-to-speech generation for the Lexigram Framework — local and API-based backends (local-http, elevenlabs, openai, chatterbox, kokoro, f5-tts, piper).


Overview

lexigram-multimedia-tts synthesizes speech from text. The default backend calls a local HTTP reference server (http://localhost:5002) so the package works out of the box with no API keys; hosted backends (ElevenLabs, OpenAI) and in-process reference servers (Chatterbox, Kokoro, F5-TTS, Piper) are selectable via config.

Full documentation: docs.lexigram.dev

Install

uv add lexigram-multimedia-tts
# Optional extras
uv add "lexigram-multimedia-tts[elevenlabs]"        # ElevenLabs API
uv add "lexigram-multimedia-tts[openai]"            # OpenAI TTS API
uv add "lexigram-multimedia-tts[chatterbox-server]" # local Chatterbox server (torch)
uv add "lexigram-multimedia-tts[kokoro-server]"     # local Kokoro server
uv add "lexigram-multimedia-tts[f5-tts-server]"     # local F5-TTS server (torch)
uv add "lexigram-multimedia-tts[piper-server]"      # local Piper server

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module
from lexigram.multimedia.tts import AudioTTSModule
from lexigram.contracts.multimedia import TTSProvider, TTSRequest


@module(imports=[AudioTTSModule.configure()])
class AppModule(Module):
    pass


async def main() -> None:
    async with Application.boot(modules=[AppModule]) as app:
        tts = await app.container.resolve(TTSProvider)
        result = await tts.generate(TTSRequest(text="Hello from Lexigram", voice="alloy"))
        if result.is_ok():
            asset = result.unwrap()  # MediaAsset — audio bytes or URI


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Configuration

Zero-config usage: Call AudioTTSModule.configure() with no arguments to use the local-http backend at http://localhost:5002.

Option 1 — YAML file

# application.yaml
multimedia:
  tts:
    backend: "elevenlabs"
    elevenlabs_voice_id: "21m00Tcm4TlvDq8ikWAM"

Option 2 — Profiles + Environment Variables

export LEX_PROFILE=production
export LEX_MULTIMEDIA__TTS__BACKEND=openai
export LEX_MULTIMEDIA__TTS__OPENAI_VOICE=echo

Option 3 — Python

from lexigram.multimedia.tts import AudioTTSModule
from lexigram.multimedia.tts.config import TTSConfig

AudioTTSModule.configure(
    config=TTSConfig(backend="elevenlabs", elevenlabs_voice_id="21m00Tcm4TlvDq8ikWAM")
)

Config reference

Field Default Env var Description
backend "local-http" LEX_MULTIMEDIA__TTS__BACKEND local-http, elevenlabs, openai, chatterbox, kokoro, f5-tts, piper
local_http_base_url "http://localhost:5002" LEX_MULTIMEDIA__TTS__LOCAL_HTTP_BASE_URL Local reference server URL
elevenlabs_voice_id None LEX_MULTIMEDIA__TTS__ELEVENLABS_VOICE_ID ElevenLabs voice ID (required for elevenlabs)
elevenlabs_api_key_secret_name "elevenlabs_api_key" LEX_MULTIMEDIA__TTS__ELEVENLABS_API_KEY_SECRET_NAME Secret name for the ElevenLabs API key
openai_api_key_secret_name "openai_api_key" LEX_MULTIMEDIA__TTS__OPENAI_API_KEY_SECRET_NAME Secret name for the OpenAI API key
openai_voice "alloy" LEX_MULTIMEDIA__TTS__OPENAI_VOICE OpenAI voice (alloy, echo, fable, onyx, nova, shimmer)
openai_model "tts-1" LEX_MULTIMEDIA__TTS__OPENAI_MODEL OpenAI TTS model
openai_base_url "https://api.openai.com" LEX_MULTIMEDIA__TTS__OPENAI_BASE_URL OpenAI-compatible base URL
chatterbox_base_url "http://localhost:5100" LEX_MULTIMEDIA__TTS__CHATTERBOX_BASE_URL Chatterbox server URL
chatterbox_exaggeration 0.5 LEX_MULTIMEDIA__TTS__CHATTERBOX_EXAGGERATION Chatterbox exaggeration factor
chatterbox_cfg_weight 0.5 LEX_MULTIMEDIA__TTS__CHATTERBOX_CFG_WEIGHT Chatterbox classifier-free guidance weight
chatterbox_temperature 0.85 LEX_MULTIMEDIA__TTS__CHATTERBOX_TEMPERATURE Chatterbox sampling temperature
kokoro_base_url "http://localhost:5101" LEX_MULTIMEDIA__TTS__KOKORO_BASE_URL Kokoro server URL
kokoro_default_voice "af_heart" LEX_MULTIMEDIA__TTS__KOKORO_DEFAULT_VOICE Default Kokoro voice
f5_tts_base_url "http://localhost:5102" LEX_MULTIMEDIA__TTS__F5_TTS_BASE_URL F5-TTS server URL
piper_base_url "http://localhost:5103" LEX_MULTIMEDIA__TTS__PIPER_BASE_URL Piper server URL
piper_default_voice "en_US-lessac-medium" LEX_MULTIMEDIA__TTS__PIPER_DEFAULT_VOICE Default Piper voice
timeout 60.0 LEX_MULTIMEDIA__TTS__TIMEOUT Request timeout in seconds

Module Factory Methods

Method Description
AudioTTSModule.configure(config) Configure with explicit TTS config
AudioTTSModule.stub() No-op module for unit testing (uses local-http)

Key Features

  • Seven backendslocal-http, elevenlabs, openai, chatterbox, kokoro, f5-tts, piper
  • Reference serverslexigram-tts-*-serve console scripts run each local model server
  • Secret-managed API keys — provider keys resolved by name through the secrets backend
  • Result-basedgenerate() -> Result[MediaAsset, MultimediaError]; errors are domain values, not exceptions

Testing

from lexigram import Application
from lexigram.multimedia.tts import AudioTTSModule

async def test_boot():
    async with Application.boot(modules=[AudioTTSModule.stub()]) as app:
        assert app.container is not None

Key Source Files

File What it contains
src/lexigram/multimedia/tts/module.py AudioTTSModule.configure() and .stub()
src/lexigram/multimedia/tts/config.py TTSConfig
src/lexigram/multimedia/tts/di/provider.py AudioTTSProvider — registers TTSProvider, wires task handlers
src/lexigram/multimedia/tts/providers/ Backend implementations (local_http, elevenlabs, openai, chatterbox, kokoro, f5_tts, piper)
src/lexigram/multimedia/tts/servers/ Reference-server entry points (lexigram-tts-*-serve)
src/lexigram/multimedia/tts/tasks.py Background generation task handlers
src/lexigram/multimedia/tts/exceptions.py TTSError hierarchy

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

lexigram_multimedia_tts-0.1.3005-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_multimedia_tts-0.1.3005-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_multimedia_tts-0.1.3005-py3-none-any.whl
Algorithm Hash digest
SHA256 4b25154c076ceea4fb6e96566841f363de669beb44a84a14bb97ff7a0b1b29f1
MD5 7ce5485c8ac89c0307312558d2f03222
BLAKE2b-256 1a85ee9f2dac780dc4b37aa57eb31afb6a0f58e1df9992ea1266b1fe297552e0

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5008

1 file

0.1.5004

2 files

0.1.5001

2 files

0.1.3007

1 file

0.1.3006

1 file

This release

0.1.3005 This release

1 file

0.1.4

2 files

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page