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() Real module pinned to the default local-http backend for tests

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 Distribution

lexigram_multimedia_tts-0.1.5004.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

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

lexigram_multimedia_tts-0.1.5004-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_multimedia_tts-0.1.5004.tar.gz.

File metadata

File hashes

Hashes for lexigram_multimedia_tts-0.1.5004.tar.gz
Algorithm Hash digest
SHA256 9f90abb11bf9fd528f19fab026213240b299d04f331078bc84571a59e5f24679
MD5 bf7b38c7a7dd89738b957c4e9e38f37b
BLAKE2b-256 df3b20e188cf14172120a148521863064f80f6a24828f205b355143782241d19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lexigram_multimedia_tts-0.1.5004-py3-none-any.whl
Algorithm Hash digest
SHA256 19b6385855e6d2551e77a7ca28e17d631779da41949318931c81d07b5f889260
MD5 1e324d39b4f0bc458ac38c49fa861443
BLAKE2b-256 6b58fc8b49007a9e4d11a82d5db77e374286ee264fcc2c0a05e6bf34ef347392

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5008

1 file

This release

0.1.5004 This release

2 files

0.1.5001

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

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