Skip to main content

Better Lyrics Translation Toolkit - AI-powered song translation with music constraint preservation

Project description

🥪 BLT - Better Lyrics Translation Toolkit

Python 3.11 License: MIT

Overview

BLT is a toolkit for song translation and voice synthesis. The toolkit contains three modular components that can be used independently or combined through pre-defined pipelines.

Toolkit Components

1. Translator

IPA-based lyrics translation tools with music constraints:

Tool Description
LyricsTranslator Main translator with syllable/rhyme preservation
LyricsAnalyzer Extract music constraints from lyrics
ConstraintValidator Validate translated lyrics against music constraints

Music Constraints Extracted:

  1. syllable_counts: list[int] (ex. [4, 3])

    • Chinese: Character-based
    • Other languages: IPA vowel nuclei
  2. syllable_patterns: list[list[int]] (ex. [[1, 1, 2], [1, 2]])

    • With audio (WIP): Alignment problem - timing sync with vocals
    • Without audio: Word segmentation problem
      • Chinese: HanLP tokenizer
      • English: Space splitting
      • Other languages: LLM-based
  3. rhyme_scheme: str (ex. AB)

    • Chinese: Pinyin finals
    • Other languages: IPA phonemes
Translation Flow
flowchart TD
    A[Source Lyrics] --> B[LyricsAnalyzer]
    B --> |Extract Constraints| C{LyricsTranslator}
    C --> |Generate Translation| D[ConstraintValidator]
    D --> |Check Constraints| E{Valid or Max Retries}
    E --> |No| C
    E --> |Yes| F[Target Lyrics]

    style B fill:#64b5f6,stroke:#1976d2,stroke-width:2px,color:#fff
    style C fill:#1976d2,stroke:#0d47a1,stroke-width:2px,color:#fff
    style D fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff

2. Synthesizer

TTS, alignment, and voice synthesis tools:

Tool Description
VocalSeparator Separate vocals from instrumental tracks
LyricsAligner Align lyrics timing with audio
VoiceSynthesizer Synthesize vocals with new lyrics

3. Pipeline

Pre-defined combinations of tools:

Pipeline Description
CoverSongPipeline End-to-end pipeline for generating translated cover songs

Setup

uv venv --python 3.11
source .venv/bin/activate
uv sync

Usage

To generate a translated cover song, use the examples/gen_translated_song.py script:

uv run python examples/gen_translated_song.py \
    --audio "path/to/your/song.mp3" \
    --old-lyrics-file "path/to/original/lyrics.txt" \
    --new-lyrics-file "path/to/new/lyrics.txt" \
    --output-name "my_cover_song"

Parameters:

  • --audio: Path to the original song audio file.
  • --old-lyrics-file: Path to a text file containing the original lyrics.
  • --new-lyrics-file: Path to a text file containing the new lyrics.
  • --output-name: The name for the generated cover song files.
  • --device: The device to run the models on (cuda or cpu).

Acknowledgments

License

Apache License 2.0

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

blt_toolkit-0.1.0.tar.gz (185.6 kB view details)

Uploaded Source

Built Distribution

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

blt_toolkit-0.1.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file blt_toolkit-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for blt_toolkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6295ecda8b6b3b318f09a435b426edb07f753bc9b5683ded8e22d14238268108
MD5 f7a280d26178daca918ab5e1127cf874
BLAKE2b-256 1774bd06ce6997d193b6ff9c293958becdc2775ad0a542d4b23c6bbd39f95ff9

See more details on using hashes here.

Provenance

The following attestation bundles were made for blt_toolkit-0.1.0.tar.gz:

Publisher: publish.yml on guan404ming/blt

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

File details

Details for the file blt_toolkit-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for blt_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30ae8634bbb3fdc8ebf7fc914d9f7e27708577d785aba407f3d36d8309a68fe8
MD5 4a9cfbd0c8d1557028a34fb51d30a72b
BLAKE2b-256 9c006debb1bfed04ee83aa1e153ee5654804d132bdd7e2bd64722b5910c58275

See more details on using hashes here.

Provenance

The following attestation bundles were made for blt_toolkit-0.1.0-py3-none-any.whl:

Publisher: publish.yml on guan404ming/blt

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