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: questionary, 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

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.

fabricatio_yue-0.3.4-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_yue-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_yue-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

File hashes

Hashes for fabricatio_yue-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6dd9f5c6327d0e9de50ce9f78b2279ac5744db22d2f283d62dc7cb6832c3adb7
MD5 d53c5fe51a1b4bf54b74e8d790767f86
BLAKE2b-256 3e536325080dba4a06a4a685a56af121023122bd82814af02e78285b25ecc3e8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.4 This release

1 file

0.3.3

1 file

0.3.2

1 file

0.3.0

1 file

0.2.13

1 file

0.2.12

1 file

0.2.11

1 file

0.2.10

1 file

0.2.9

1 file

0.2.7

1 file

0.2.6

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page