Woking with .lrc files

install dependencies

[1]:
%pip install lrctoolbox
from IPython.display import clear_output
clear_output()

Load lyrics from .lrc file

[2]:
from lrctoolbox import SyncedLyrics

# Load LRC file
lyrics = SyncedLyrics.load_from_file("example.lrc")

Modify lyrics timestamp

[3]:
# check if lyrics are synced
assert lyrics.is_synced

# get lyrics as string
print(lyrics.lyrics)

# shift lyrics by 1 second
for line in lyrics:
    line.timestamp += 1000

# print shifted lyrics
print(lyrics.lyrics)
['[00:27.76] Silent night, holy night', '[00:34.10] All is calm and all is bright', '[00:40.14] Round yon virgin mother and child', '[00:46.70] Holy infant so tender and mild']
['[00:28.76] Silent night, holy night', '[00:35.10] All is calm and all is bright', '[00:41.14] Round yon virgin mother and child', '[00:47.70] Holy infant so tender and mild']

Modify lyrics metadata

[4]:
print(f"Artist: {lyrics.artist}", f"Title: {lyrics.title}", sep="\n")
# change the artist
lyrics.artist = "New Artist"

# change the title
lyrics.title = "New Title"

print(f"Artist: {lyrics.artist}", f"Title: {lyrics.title}", sep="\n")
Artist: Taylor Swift
Title: Silent night
Artist: New Artist
Title: New Title