Skip to main content

Automatically create synchronised lyrics files in ASS and MidiCo LRC formats with word-level timestamps, using Whisper and lyrics from Genius and Spotify

Project description

Lyrics Transcriber 🎶

PyPI version

Automatically create synchronised lyrics files in ASS and MidiCo LRC formats with word-level timestamps, using OpenAI Whisper and lyrics from Genius and Spotify, for convenience in use cases such as karaoke video production.

Features 🌟

  • Automatically transcribe lyrics with word-level timestamps.
  • Outputs lyrics in ASS and MidiCo LRC formats.
  • Can fetch lyrics from with Genius and Spotify.
  • Command Line Interface (CLI) for easy usage.
  • Can be included and used in other Python projects.

Installation 🛠️

Prerequisites

  • Python 3.9 or higher
  • [Optional] Genius API token if you want to fetch lyrics from Genius
  • [Optional] Spotify cookie value if you want to fetch lyrics from Spotify
  • [Optional] OpenAI API token if you want to use LLM correction of the transcribed lyrics
  • [Optional] AudioShake API token if you want to use a much higher quality (but paid) API for lyrics transcription
pip install lyrics-transcriber

Warning The package published to PyPI was created by manually editing poetry.lock to remove triton, as it is technically a sub-dependency from openai-whisper but is currently only supported on Linux (whisper still works fine without it, and I want this package to be usable on any platform)

Docker

You can use the pre-built container image beveradb/lyrics-transcriber:0.16.0 on Docker hub if you want, here's an example:

docker run \
 -v `pwd`/input:/input \
 -v `pwd`/output:/output \
beveradb/lyrics-transcriber:0.16.0 \
 --log_level debug \
 --output_dir /output \
 --render_video \
 --video_background_image /input/your-background-image.png \
 --video_resolution 360p \
 /input/song.flac

Usage 🚀

As a standalone CLI

  1. To transcribe lyrics from an audio file:
lyrics-transcriber /path/to/your/audiofile.mp3
  1. To specify Genius API token, song artist, and song title for auto-correction:
lyrics-transcriber /path/to/your/audiofile.mp3 --genius_api_token YOUR_API_TOKEN --artist "Artist Name" --title "Song Title"

As a Python package in your project

  1. Import LyricsTranscriber in your Python script:
from lyrics_transcriber import LyricsTranscriber
  1. Create an instance and use it:
transcriber = LyricsTranscriber(audio_filepath='path_to_audio.mp3')
result_metadata = transcriber.generate()

result_metadata contains values as such:

result_metadata = {
    "whisper_json_filepath": str,
    "genius_lyrics": str,
    "genius_lyrics_filepath": str,
    "midico_lrc_filepath": str,
    "singing_percentage": int,
    "total_singing_duration": int,
    "song_duration": int,
}

Requirements 📋

  • Python >= 3.9
  • Python Poetry
  • Dependencies are listed in pyproject.toml

Local Development 💻

To work on the Lyrics Transcriber project locally, you need Python 3.9 or higher. It's recommended to create a virtual environment using poetry.

  1. Clone the repo and cd into it.
  2. Install poetry if you haven’t already.
  3. Run poetry install to install the dependencies.
  4. Run poetry shell to activate the virtual environment.

Contributing 🤝

Contributions are very much welcome! Please fork the repository and submit a pull request with your changes, and I'll try to review, merge and publish promptly!

  • This project is 100% open-source and free for anyone to use and modify as they wish.
  • If the maintenance workload for this repo somehow becomes too much for me I'll ask for volunteers to share maintainership of the repo, though I don't think that is very likely

License 📄

This project is licensed under the MIT License.

Credits 🙏

  • This project uses OpenAI Whisper for transcription, which inspired the entire tool!
  • Thanks to @linto-ai for the whisper-timestamped project which solved a big chunk for me.
  • Thanks to Genius for providing an API which makes fetching lyrics easier!

Contact 💌

For questions or feedback, please raise an issue or reach out to @beveradb (Andrew Beveridge) directly.

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

lyrics_transcriber-0.17.2.tar.gz (43.7 kB view details)

Uploaded Source

Built Distribution

lyrics_transcriber-0.17.2-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

Details for the file lyrics_transcriber-0.17.2.tar.gz.

File metadata

  • Download URL: lyrics_transcriber-0.17.2.tar.gz
  • Upload date:
  • Size: 43.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for lyrics_transcriber-0.17.2.tar.gz
Algorithm Hash digest
SHA256 0ee321c633987521f9f4ce2a77cb05b5c9d276d6a34254940230e0c6f0789333
MD5 0353f14a0de04d45cc703fd1f4b993e9
BLAKE2b-256 7351bf2fd0f8aef5cdd8fe3ca1cf318c7afc1b9c11d0cec75b5618d6e44094e1

See more details on using hashes here.

File details

Details for the file lyrics_transcriber-0.17.2-py3-none-any.whl.

File metadata

File hashes

Hashes for lyrics_transcriber-0.17.2-py3-none-any.whl
Algorithm Hash digest
SHA256 18487be8360b3ed6cfdad87664f23110d714ce7346d170fc84ba532aea5d0e88
MD5 aeca3bcc8fba016c0fe6ba02791d1ab3
BLAKE2b-256 823cb4881a34bf209fc11d173e19e61196201376a6ecb2c1020de36a58dcbc2a

See more details on using hashes here.

Supported by

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