Skip to main content

fabricatio-yue

MIT License Python Versions PyPI Version PyPI Downloads PyPI Downloads

AI-powered lyrics composition for music generation with YuE. Provides genre selection, structured lyric generation, and batch song composition integrated into the Fabricatio agent framework.

Installation

pip install fabricatio[yue]

Or with the CLI extras:

pip install fabricatio[yue,cli]

Overview

fabricatio-yue generates complete song lyrics with genre-appropriate structure (verse, chorus, bridge, etc.). It selects suitable genres from a taxonomy of 200+ tags across five categories — genre, instrument, mood, gender, timbre — and feeds them into LLM-driven lyric generation. Songs are saved as Markdown files with embedded metadata.

Key Components

Models

Class Description
Segment A song section with section_type (verse, chorus, bridge, intro, outro, etc.), duration in seconds, lyrics as lines, and optional extra_genres. assemble property formats it as [section_type]\nlyrics.
Song A complete song with name, description, genres, and an ordered list of Segments. Computes total duration from segments. save_to(path) writes it as a Markdown file.

Capabilities

Class Description
SelectGenre Selects genres from a category based on text requirements. select_genre(req, classifier, genres) picks matching genres; gather_genres(req) iterates all categories and returns the combined results.
Lyricize Extends Propose and SelectGenre. lyricize(requirement) gathers genres, renders a prompt template, and returns a Song object. Accepts a single string or a list for batch generation.

Actions

Class Description
Compose Full pipeline action: _execute(req, output) calls lyricize() then save_to(output). Usable in a WorkFlow step.

CLI

yuek compose -r "an upbeat pop song about summer" -o ./output

Usage

from fabricatio_core import Event, Role, Task, WorkFlow
from fabricatio_yue.actions.compose import Compose

ns = "compose"
Role.with_bio(name="composer").subscribe(
    Event.quick_instantiate(ns),
    WorkFlow(steps=(Compose().to_task_output(),))
).dispatch()

Task(name="compose song").update_init_context(
    req="a melancholic jazz ballad",
    output="./songs",
).delegate_blocking(ns)

Using the Lyricize capability directly:

from fabricatio_yue.capabilities.lyricize import Lyricize

lyricizer = Lyricize()
song = await lyricizer.lyricize("a fast punk anthem about resilience")
print(song.model_dump_json(indent=2))

Using SelectGenre:

from fabricatio_yue.capabilities.genre import SelectGenre

selector = SelectGenre()
genres = await selector.gather_genres("dark atmospheric electronic")

Song and Segment model usage:

from fabricatio_yue.models.segment import Segment, Song

segments = [
    Segment(section_type="verse", duration=30, lyrics=["First verse line 1", "First verse line 2"]),
    Segment(section_type="chorus", duration=20, lyrics=["Chorus line 1", "Chorus line 2"]),
]

song = Song(
    name="my_song",
    description="A generated song",
    genres=["electronic", "ambient"],
    segments=segments,
)

song.save_to("./songs")
print(song.duration)  # 50

Dependencies

  • fabricatio-core — core agent framework
  • more-itertools — flatten genre results
  • orjson — fast JSON loading of genre tags
  • pydantic — data model validation

Optional CLI extras: typer.

Configuration

All options below are read through the fabricatio configuration chain (see the Configuration Guide). Set them under the [ext.yue] table in fabricatio.toml, equivalently under [tool.fabricatio.ext.yue] in pyproject.toml, or via FABRICATIO_EXT__YUE__<FIELD_UPPER> environment variables.

[ext.yue]
Option Type Default Description
segment_types List[str] ["verse", "chorus", "bridge", "intro", "outro", "solo", "beat", "end"] List of valid segment types for music composition.
genre Dict[str, List[str]] (see config.py) Dictionary mapping genre categories to lists of specific genres.
lyricize_template str "built-in/lyricize" Template name for lyric generation.
select_genre_template str "built-in/select_genre" Template name for genre selection.
song_save_template str "built-in/song_save" Template name for saving a song.

Access at runtime: from fabricatio_yue.config import yue_config.

License

MIT — see LICENSE

Metadata

Release files for fabricatio-yue 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for fabricatio-yue 0.4.0
File Interpreter ABI Platform
fabricatio_yue-0.4.0-py3-none-any.whl Python 3 none any Details

Release files / fabricatio_yue-0.4.0-py3-none-any.whl

Download URL fabricatio_yue-0.4.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b9d1caea5945ea4be69fb655630c1cfc4d5fcb8a9647e9bd38d6a7012b62a06
BLAKE2b-256 checksum
How to use checksums
dfaa99e441064105b71912380160e3bdc9d01d998a5c3b88ece943c9e6ae8e81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
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