Skip to main content

An extension of fabricatio, provide capability to compose lyrics that can be used in music generation with YuE.

Project description

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().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

Settings are loaded via fabricatio_yue.config.yue_config (an instance of YueConfig). Key options:

  • segment_types — list of valid section types (default: ["verse", "chorus", "bridge", "intro", "outro", "solo", "beat", "end"])
  • genre — dict mapping category to list of genres, loaded from top_200_tags.json
  • lyricize_template, select_genre_template, song_save_template — template names for LLM prompts

License

MIT — see LICENSE

Project details


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.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fabricatio_yue-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b565b8bc2707b38ed699f9ff29835f27dec671412c70e6a6c7f18f2c5d1c8568
MD5 87b65851caa259a69b525517ef846357
BLAKE2b-256 45caf359527ca1a3455d38697572fe58c178e22d2f3620c2c3cc69e7c8b32f1e

See more details on using hashes here.

Supported by

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