From 5d5cb0e6f27c37a220d419e38166e1c9856c3b32 Mon Sep 17 00:00:00 2001 From: Brosef Date: Wed, 17 Dec 2025 12:21:07 +0000 Subject: [PATCH] Implemented first version of exportLRC --- exportLRC.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 exportLRC.py diff --git a/exportLRC.py b/exportLRC.py new file mode 100644 index 0000000..8fe5035 --- /dev/null +++ b/exportLRC.py @@ -0,0 +1,33 @@ +""" +Exports the lyric track in Audacity to an LRC file. +""" + +import argparse +import os + +import utils + +parser = argparse.ArgumentParser( + description='Exports the lyric track in Audacity to an LRC file.') +parser.add_argument('lrcFile', nargs='?', default='./output.lrc', help='The .lrc file to export.') +args = parser.parse_args() + +if os.path.isfile(args.lrcFile): + i = utils.inputYN(f'"{args.lrcFile}" already exists, would you like to overwrite it? (y/n) > ') + if not i: + print('User abort.') + exit() + +lrcIdx = utils.getLRCTrackIndex() + +if lrcIdx is None: + print('No lyric track was found in Audacity.') + print('Please either use importLRC.py, or create a label track called "Lyrics".') + exit(1) + +labels = [data[1] for data in utils.getInfo('Labels') if data[0] == lrcIdx][0] + +with open(args.lrcFile, 'w', encoding='utf-8') as f: + for label in labels: + f.write(utils.generateLRCLine(label[0], label[2])) + f.write('\n')