Quickstart: lexigram-multimedia-music
Generate music and sound effects from a text prompt, wired through the Lexigram DI container. The default backend talks to a local HTTP reference server, so it works with zero API keys.
Install
Section titled “Install”uv add lexigram-multimedia-musicOptional extras pull in a backend’s model runtime for local inference:
uv add "lexigram-multimedia-music[ace-step-server]" # local ACE-Step full-song server (torch)uv add "lexigram-multimedia-music[stable-audio-open-server]" # local Stable Audio Open FX server (torch)
lexigram-multimedia-musicdepends onlexigramandlexigram-contracts(installed automatically).aiohttpis a hard dependency used by every backend.
Minimal Working Example
Section titled “Minimal Working Example”import asyncio
from lexigram import Applicationfrom lexigram.contracts.multimedia import MusicProvider, MusicRequestfrom lexigram.di.module import Module, modulefrom lexigram.multimedia.music import AudioMusicModule
@module(imports=[AudioMusicModule.configure()])class AppModule(Module): pass
async def main() -> None: async with Application.boot(modules=[AppModule]) as app: music = await app.container.resolve(MusicProvider) result = await music.generate(MusicRequest(prompt="upbeat synthwave, 120 bpm")) if result.is_ok(): asset = result.unwrap() # MediaAsset — raw WAV/MP3 bytes print(asset.mime_type, asset.has_bytes)
asyncio.run(main())Run a local music server in a separate terminal first (any of the *-serve scripts), or point the config at an already-running host:
lexigram-music-stable-audio-open-serve # serves /generate and /health on :5301What Just Happened
Section titled “What Just Happened”AudioMusicModule.configure()created aDynamicModulecarryingAudioMusicProvider, exporting theMusicProvidercontract andMusicGenerationTask.Application.boot()ran the provider lifecycle:- register —
MusicConfigis bound as a singleton; the provider constructs the configured backend (LocalHttpMusicProviderby default) and binds it asMusicProvider, plus aMusicGenerationTaskwrapper. - boot — no extra async I/O (all wiring happened in
register()).
- register —
- Calling
music.generate(MusicRequest(...))POSTs to{backend_base_url}/generateand returns aResult[MediaAsset, MusicGenerationError]— never raises for a domain failure. TheMediaAssetcarriesmime_type,provider, andbytes_data.
Next Steps
Section titled “Next Steps”- Guide — mental model, the four backends, common patterns
- How-Tos — task-oriented recipes
- Configuration — every config key and env-var override
- Architecture — internal design and extension points
- Troubleshooting — common failures and fixes