From 40e726e6a4e297df7c676417f828441118c65cd2 Mon Sep 17 00:00:00 2001 From: Brosef Date: Tue, 16 Dec 2025 20:38:42 +0000 Subject: [PATCH] Implemented first version of importLRC --- importLRC.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 importLRC.py diff --git a/importLRC.py b/importLRC.py new file mode 100644 index 0000000..df1b21a --- /dev/null +++ b/importLRC.py @@ -0,0 +1,36 @@ +""" +Imports an LRC file (with or without timestamps) into Audacity. +""" + +import argparse + +import utils + +parser = argparse.ArgumentParser( + description='Imports an LRC file (with or without timestamps) into Audacity.') +parser.add_argument('lrcFile', nargs='?', default=None, help='The .lrc file to import.') +args = parser.parse_args() + +lyrics = [] + +if args.lrcFile is None: + print('No .lrc file was passed, please paste the lyrics, then enter \'/\' to continue.') + i = '' + while i != '/': + i = input('') + lyrics.append(i) + lyrics.pop(-1) +else: + with open(args.lrcFile, 'r', encoding='utf-8') as f: + lyrics = f.read().split('\n') + +lyrics = [utils.parseLrcLine(lrcLine) for lrcLine in lyrics] + +lrcidx = utils.getLRCTrackIndex(True) +projectLen = utils.getProjectLength() + +for idx, (t, lyric) in enumerate(lyrics): + if t is None: + t = idx * (projectLen / len(lyrics)) + + utils.addLabel(lrcidx, t, lyric)