Skip to main content

AI-powered LRC generator with Whisper and LLM correction

Project description

lrcgen

AI-powered LRC generator using Whisper + optional LLM correction.

Install

pip install lrcgen

Optional extras:

# enable online LLM correction
pip install "lrcgen[online]"

# enable OpenCC (Traditional→Simplified conversion)
pip install "lrcgen[opencc]"

# enable both
pip install "lrcgen[full]"

Requirements

  • Offline transcription uses Whisper models (first run may download model files).
  • Online correction requires OPENAI_API_KEY (or a compatible API via OPENAI_BASE_URL).

Usage

# batch
lrcgen input/ output/
lrcgen input/ output/ --offline
lrcgen input/ output/ --online

# single file
lrcgen --audio input/song.mp3 --output out.lrc --offline

# choose whisper model/language
lrcgen --audio input/song.mp3 --output out.lrc --offline --model large-v3 --language zh

# force GPU / pick CUDA device
lrcgen --audio input/song.mp3 --output out.lrc --offline --device cuda --cuda-device 0

# lyrics-guided generation (use your full lyrics as the "source of truth")
# lyrics can be out-of-order; txt or lrc both work
lrcgen --audio input/song.mp3 --output out.lrc --offline --lyrics-file input/lyrics.txt

# tune lyrics matching (example: aim for >=90% lines replaced by canonical lyrics)
lrcgen --audio input/song.mp3 --output out.lrc --offline --lyrics-file input/lyrics.txt --lyrics-target-coverage 0.90

# by default, target coverage is 0.90; disable auto-relax by setting 0
lrcgen --audio input/song.mp3 --output out.lrc --offline --lyrics-file input/lyrics.txt --lyrics-target-coverage 0

# tweak strictness (default min score is 0.50)
lrcgen --audio input/song.mp3 --output out.lrc --offline --lyrics-file input/lyrics.txt --lyrics-min-score 0.60

# module entrypoint (same as lrcgen command)
python -m lrcgen --audio input/song.mp3 --output out.lrc --offline

# version
python -m lrcgen --version

Online config

Set env vars (e.g. via .env):

  • OPENAI_API_KEY=...
  • OPENAI_BASE_URL=https://api.openai.com/v1 (optional)
  • OPENAI_MODEL=gpt-4o-mini (optional)

Library usage

from lrcgen.api import generate_lrc_sync

generate_lrc_sync("input/song.mp3", "out.lrc", mode="offline")

Project structure

genlrc/
	README.md
	pyproject.toml
	music_to_lrc_batch.py
	lrcgen/
		__init__.py        # package version
		__main__.py        # enables: python -m lrcgen
		cli.py             # argparse CLI entrypoint
		api.py             # stable library API (sync + async)
		whisperer.py       # Whisper transcription wrapper
		corrector.py       # optional LLM correction + guardrails
		lyrics_aligner.py  # align transcript lines to user-provided full lyrics
		utils.py           # time formatting + basic text cleaning
		config.py          # env/.env config (OPENAI_*, etc.)
		input/             # optional local test inputs (not packaged)
		output/            # optional local outputs (not packaged)
	test/
		test.py            # small unittest suite
	tools/
		clean.py           # removes dist/build/cache artifacts
	.github/workflows/
		ci.yml             # CI build + checks
		publish.yml        # tag-based publish via PyPI Trusted Publishing (OIDC)

How it fits together:

  • CLI: lrcgen/cli.py parses args and calls lrcgen/api.py.
  • Core pipeline: whisperer.py transcribes audio → utils.py cleans → corrector.py optionally fixes lines → writes .lrc.
  • Configuration: config.py loads environment variables (and .env if present).

Features

  • Offline Whisper transcription
  • Optional LLM correction
  • Simplified Chinese output
  • Batch processing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lrcgen-0.2.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

lrcgen-0.2.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file lrcgen-0.2.0.tar.gz.

File metadata

  • Download URL: lrcgen-0.2.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lrcgen-0.2.0.tar.gz
Algorithm Hash digest
SHA256 153bfcb40816a41c747114ba736dfcd59b29219b6e915d9da2fa18dceaa1b5b4
MD5 34c6b03a9b9a82edf193a8f395909f99
BLAKE2b-256 f8fc62ac2a721642ecff3677b28c6a5d5b5ba17dc9587a25ba2369c2fdf0dda3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lrcgen-0.2.0.tar.gz:

Publisher: publish.yml on lihan3238/genlrc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lrcgen-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lrcgen-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lrcgen-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2be31f24129b3cafaf2ee7dd4397085700c931c3ed81232147dfac5a9a98939
MD5 0f0e7d03eed62ee2738d77be4279c670
BLAKE2b-256 5d4b3c8c0cffa26be9a85ed68e3af42e075b90e6e4d0a635fdf045b340816b35

See more details on using hashes here.

Provenance

The following attestation bundles were made for lrcgen-0.2.0-py3-none-any.whl:

Publisher: publish.yml on lihan3238/genlrc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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