mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
Updated to use latest lyrics transcriber. Added full auto and bulk processing modes. Added ability to pass in existing lyrics input file.
This commit is contained in:
7 files changed
+465
-32
No files matched your search
@@ -1,6 +1,7 @@
|
||||
# Andrew env
|
||||
.DS_Store
|
||||
.vscode
|
||||
*.csv
|
||||
|
||||
# Andrew functional adds
|
||||
audio/
|
||||
|
||||
@@ -12,6 +12,8 @@ from lyrics_transcriber import LyricsTranscriber, OutputConfig, TranscriberConfi
|
||||
from pydub import AudioSegment
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
import asyncio
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
|
||||
class KaraokePrep:
|
||||
@@ -47,6 +49,7 @@ class KaraokePrep:
|
||||
# Lyrics Configuration
|
||||
lyrics_artist=None,
|
||||
lyrics_title=None,
|
||||
lyrics_file=None,
|
||||
skip_lyrics=False,
|
||||
skip_transcription=False,
|
||||
# Style Configuration
|
||||
@@ -100,6 +103,7 @@ class KaraokePrep:
|
||||
self.lyrics = None
|
||||
self.lyrics_artist = lyrics_artist
|
||||
self.lyrics_title = lyrics_title
|
||||
self.lyrics_file = lyrics_file
|
||||
self.skip_lyrics = skip_lyrics
|
||||
self.skip_transcription = skip_transcription
|
||||
|
||||
@@ -501,6 +505,7 @@ class KaraokePrep:
|
||||
lyrics_config = LyricsConfig(
|
||||
genius_api_token=env_config.get("genius_api_token"),
|
||||
spotify_cookie=env_config.get("spotify_cookie"),
|
||||
lyrics_file=self.lyrics_file,
|
||||
)
|
||||
|
||||
output_config = OutputConfig(
|
||||
@@ -1226,13 +1231,12 @@ class KaraokePrep:
|
||||
self.logger.info(f"File already exists, skipping creation: {file_path}")
|
||||
return exists
|
||||
|
||||
def prep_single_track(self):
|
||||
async def prep_single_track(self):
|
||||
self.logger.info(f"Preparing single track: {self.artist} - {self.title}")
|
||||
|
||||
if self.input_media is not None and os.path.isfile(self.input_media):
|
||||
self.extractor = "Original"
|
||||
else:
|
||||
# Parses metadata in self.extracted_info to set vars: self.url, self.extractor, self.media_id, self.artist, self.title
|
||||
self.parse_single_track_metadata(input_artist=self.artist, input_title=self.title)
|
||||
|
||||
self.logger.info(f"Preparing output path for track: {self.title} by {self.artist}")
|
||||
@@ -1314,11 +1318,19 @@ class KaraokePrep:
|
||||
lyrics_artist = self.lyrics_artist or self.artist
|
||||
lyrics_title = self.lyrics_title or self.title
|
||||
|
||||
transcriber_outputs = self.transcribe_lyrics(processed_track["input_audio_wav"], lyrics_artist, lyrics_title, track_output_dir)
|
||||
# Start transcription in a separate thread if lyrics are enabled
|
||||
transcription_future = None
|
||||
transcription_future = self.transcribe_lyrics(processed_track["input_audio_wav"], lyrics_artist, lyrics_title, track_output_dir)
|
||||
|
||||
if transcriber_outputs:
|
||||
self.lyrics = transcriber_outputs.get("corrected_lyrics_text")
|
||||
processed_track["lyrics"] = transcriber_outputs.get("corrected_lyrics_text_filepath")
|
||||
# Wait for transcription to complete if it was started
|
||||
if transcription_future:
|
||||
try:
|
||||
transcriber_outputs = await transcription_future
|
||||
if transcriber_outputs:
|
||||
self.lyrics = transcriber_outputs.get("corrected_lyrics_text")
|
||||
processed_track["lyrics"] = transcriber_outputs.get("corrected_lyrics_text_filepath")
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error during lyrics transcription: {e}")
|
||||
|
||||
output_image_filepath_noext = os.path.join(track_output_dir, f"{artist_title} (Title)")
|
||||
processed_track["title_image_png"] = f"{output_image_filepath_noext}.png"
|
||||
@@ -1362,7 +1374,7 @@ class KaraokePrep:
|
||||
|
||||
return processed_track
|
||||
|
||||
def process_playlist(self):
|
||||
async def process_playlist(self):
|
||||
if self.artist is None or self.title is None:
|
||||
raise Exception("Error: Artist and Title are required for processing a local file.")
|
||||
|
||||
@@ -1373,14 +1385,14 @@ class KaraokePrep:
|
||||
self.extracted_info = entry
|
||||
self.logger.info(f"Processing playlist entry with title: {self.extracted_info['title']}")
|
||||
if not self.dry_run:
|
||||
track_results.append(self.prep_single_track())
|
||||
track_results.append(await self.prep_single_track())
|
||||
self.artist = self.persistent_artist
|
||||
self.title = None
|
||||
return track_results
|
||||
else:
|
||||
raise Exception(f"Failed to find 'entries' in playlist, cannot process")
|
||||
|
||||
def process_folder(self):
|
||||
async def process_folder(self):
|
||||
if self.filename_pattern is None or self.artist is None:
|
||||
raise Exception("Error: Filename pattern and artist are required for processing a folder.")
|
||||
|
||||
@@ -1412,7 +1424,7 @@ class KaraokePrep:
|
||||
track_output_dir = os.path.join(output_folder_path, f"{track_index} - {self.artist} - {title}")
|
||||
|
||||
if not self.dry_run:
|
||||
track = self.prep_single_track()
|
||||
track = await self.prep_single_track()
|
||||
tracks.append(track)
|
||||
|
||||
# Move the track folder to the output folder
|
||||
@@ -1423,25 +1435,21 @@ class KaraokePrep:
|
||||
|
||||
return tracks
|
||||
|
||||
def process(self):
|
||||
async def process(self):
|
||||
if self.input_media is not None and os.path.isdir(self.input_media):
|
||||
self.logger.info(f"Input media {self.input_media} is a local folder, processing each file individually...")
|
||||
|
||||
return self.process_folder()
|
||||
return await self.process_folder()
|
||||
elif self.input_media is not None and os.path.isfile(self.input_media):
|
||||
self.logger.info(f"Input media {self.input_media} is a local file, youtube logic will be skipped")
|
||||
|
||||
return [self.prep_single_track()]
|
||||
return [await self.prep_single_track()]
|
||||
else:
|
||||
self.url = self.input_media
|
||||
# Runs yt-dlp extract_info for input URL or artist/title search query to set var: self.extracted_info
|
||||
# We do this first as the input URL may be a playlist
|
||||
self.extract_info_for_online_media(input_url=self.url, input_artist=self.artist, input_title=self.title)
|
||||
|
||||
if self.extracted_info and "playlist_count" in self.extracted_info:
|
||||
self.persistent_artist = self.artist
|
||||
self.logger.info(f"Input URL is a playlist, beginning batch operation with persistent artist: {self.persistent_artist}")
|
||||
return self.process_playlist()
|
||||
return await self.process_playlist()
|
||||
else:
|
||||
self.logger.info(f"Input URL is not a playlist, processing single track")
|
||||
return [self.prep_single_track()]
|
||||
return [await self.prep_single_track()]
|
||||
@@ -0,0 +1,224 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import logging
|
||||
import pkg_resources
|
||||
import os
|
||||
import sys
|
||||
import asyncio
|
||||
import json
|
||||
from karaoke_prep import KaraokePrep
|
||||
from karaoke_prep.karaoke_finalise import KaraokeFinalise
|
||||
|
||||
|
||||
async def async_main():
|
||||
logger = logging.getLogger(__name__)
|
||||
log_handler = logging.StreamHandler()
|
||||
log_formatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
log_handler.setFormatter(log_formatter)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Automatically prepare and finalise karaoke videos in one step, combining karaoke-prep and karaoke-finalise functionality.",
|
||||
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=54),
|
||||
)
|
||||
|
||||
# Basic information (from prep_cli.py)
|
||||
parser.add_argument(
|
||||
"args",
|
||||
nargs="*",
|
||||
help="[Media or playlist URL] [Artist] [Title] of song to prep. If URL is provided, Artist and Title are optional but increase chance of fetching the correct lyrics. If Artist and Title are provided with no URL, the top YouTube search result will be fetched.",
|
||||
)
|
||||
|
||||
package_version = pkg_resources.get_distribution("karaoke-prep").version
|
||||
parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {package_version}")
|
||||
|
||||
# Common arguments for both prep and finalise
|
||||
parser.add_argument(
|
||||
"--log_level",
|
||||
default="info",
|
||||
help="Optional: logging level, e.g. info, debug, warning (default: %(default)s). Example: --log_level=debug",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dry_run",
|
||||
action="store_true",
|
||||
help="Optional: perform a dry run without making any changes. Example: --dry_run",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--style_params_json",
|
||||
help="Optional: Path to JSON file containing style configuration. Example: --style_params_json='/path/to/style_params.json'",
|
||||
)
|
||||
|
||||
# Prep-specific arguments (add any additional prep arguments you commonly use)
|
||||
parser.add_argument(
|
||||
"--output_dir",
|
||||
default=".",
|
||||
help="Optional: directory to write output files (default: <current dir>). Example: --output_dir=/app/karaoke",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no_track_subfolders",
|
||||
action="store_false",
|
||||
dest="create_track_subfolders",
|
||||
help="Optional: do NOT create a named subfolder for each track. Example: --no_track_subfolders",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--existing_instrumental",
|
||||
help="Optional: Path to an existing instrumental audio file. If provided, audio separation will be skipped.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lyrics_file",
|
||||
help="Optional: Path to a file containing lyrics to use instead of fetching from online. Example: --lyrics_file='/path/to/lyrics.txt'",
|
||||
)
|
||||
|
||||
# Finalise-specific arguments
|
||||
parser.add_argument(
|
||||
"--enable_cdg",
|
||||
action="store_true",
|
||||
help="Optional: Enable CDG ZIP generation during finalisation. Example: --enable_cdg",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--enable_txt",
|
||||
action="store_true",
|
||||
help="Optional: Enable TXT ZIP generation during finalisation. Example: --enable_txt",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--brand_prefix",
|
||||
help="Optional: Your brand prefix to calculate the next sequential number. Example: --brand_prefix=BRAND",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--organised_dir",
|
||||
help="Optional: Target directory where the processed folder will be moved. Example: --organised_dir='/path/to/Tracks-Organized'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--organised_dir_rclone_root",
|
||||
help="Optional: Rclone path which maps to your organised_dir. Example: --organised_dir_rclone_root='dropbox:Media/Karaoke/Tracks-Organized'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--public_share_dir",
|
||||
help="Optional: Public share directory for final files. Example: --public_share_dir='/path/to/Tracks-PublicShare'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--youtube_client_secrets_file",
|
||||
help="Optional: Path to youtube client secrets file. Example: --youtube_client_secrets_file='/path/to/client_secret.json'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--youtube_description_file",
|
||||
help="Optional: Path to youtube description template. Example: --youtube_description_file='/path/to/description.txt'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rclone_destination",
|
||||
help="Optional: Rclone destination for public_share_dir sync. Example: --rclone_destination='googledrive:KaraokeFolder'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--discord_webhook_url",
|
||||
help="Optional: Discord webhook URL for notifications. Example: --discord_webhook_url='https://discord.com/api/webhooks/...'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--email_template_file",
|
||||
help="Optional: Path to email template file. Example: --email_template_file='/path/to/template.txt'",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Parse input arguments similar to prep_cli.py
|
||||
input_media, artist, title = None, None, None
|
||||
|
||||
if not args.args:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
if args.args[0].startswith(("http://", "https://")) or os.path.isfile(args.args[0]):
|
||||
input_media = args.args[0]
|
||||
if len(args.args) > 2:
|
||||
artist = args.args[1]
|
||||
title = args.args[2]
|
||||
elif len(args.args) > 1:
|
||||
artist = args.args[0]
|
||||
title = args.args[1]
|
||||
else:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
log_level = getattr(logging, args.log_level.upper())
|
||||
logger.setLevel(log_level)
|
||||
|
||||
# Step 1: Run KaraokePrep
|
||||
logger.info("Starting preparation phase...")
|
||||
kprep = KaraokePrep(
|
||||
artist=artist,
|
||||
title=title,
|
||||
input_media=input_media,
|
||||
dry_run=args.dry_run,
|
||||
log_formatter=log_formatter,
|
||||
log_level=log_level,
|
||||
output_dir=args.output_dir,
|
||||
create_track_subfolders=True if not hasattr(args, "create_track_subfolders") else args.create_track_subfolders,
|
||||
style_params_json=args.style_params_json,
|
||||
existing_instrumental=args.existing_instrumental,
|
||||
lyrics_file=args.lyrics_file,
|
||||
)
|
||||
|
||||
tracks = await kprep.process()
|
||||
|
||||
# Step 2: For each track, run KaraokeFinalise
|
||||
for track in tracks:
|
||||
logger.info(f"Starting finalisation phase for {track['artist']} - {track['title']}...")
|
||||
|
||||
# Change to the track directory - use the output directory structure
|
||||
track_dir = os.path.join(args.output_dir, f"{track['artist']} - {track['title']}")
|
||||
if not os.path.exists(track_dir):
|
||||
logger.error(f"Track directory not found: {track_dir}")
|
||||
continue
|
||||
|
||||
logger.info(f"Changing to directory: {track_dir}")
|
||||
os.chdir(track_dir)
|
||||
|
||||
# Load CDG styles if CDG generation is enabled
|
||||
cdg_styles = None
|
||||
if args.enable_cdg:
|
||||
if not args.style_params_json:
|
||||
logger.error("CDG styles JSON file path (--style_params_json) is required when --enable_cdg is used")
|
||||
sys.exit(1)
|
||||
try:
|
||||
with open(args.style_params_json, "r") as f:
|
||||
style_params = json.loads(f.read())
|
||||
cdg_styles = style_params["cdg"]
|
||||
except FileNotFoundError:
|
||||
logger.error(f"CDG styles configuration file not found: {args.style_params_json}")
|
||||
sys.exit(1)
|
||||
except json.JSONDecodeError as e:
|
||||
logger.error(f"Invalid JSON in CDG styles configuration file: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
# Initialize KaraokeFinalise
|
||||
kfinalise = KaraokeFinalise(
|
||||
log_formatter=log_formatter,
|
||||
log_level=log_level,
|
||||
dry_run=args.dry_run,
|
||||
enable_cdg=args.enable_cdg,
|
||||
enable_txt=args.enable_txt,
|
||||
brand_prefix=args.brand_prefix,
|
||||
organised_dir=args.organised_dir,
|
||||
organised_dir_rclone_root=args.organised_dir_rclone_root,
|
||||
public_share_dir=args.public_share_dir,
|
||||
youtube_client_secrets_file=args.youtube_client_secrets_file,
|
||||
youtube_description_file=args.youtube_description_file,
|
||||
rclone_destination=args.rclone_destination,
|
||||
discord_webhook_url=args.discord_webhook_url,
|
||||
email_template_file=args.email_template_file,
|
||||
cdg_styles=cdg_styles,
|
||||
)
|
||||
|
||||
try:
|
||||
final_track = kfinalise.process()
|
||||
logger.info(f"Successfully completed auto processing for: {track['artist']} - {track['title']}")
|
||||
except Exception as e:
|
||||
logger.error(f"Error during finalisation: {str(e)}")
|
||||
raise e
|
||||
|
||||
|
||||
def main():
|
||||
asyncio.run(async_main())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import logging
|
||||
import pkg_resources
|
||||
import os
|
||||
import csv
|
||||
import asyncio
|
||||
from karaoke_prep import KaraokePrep
|
||||
from karaoke_prep.karaoke_finalise import KaraokeFinalise
|
||||
|
||||
|
||||
async def process_track(row, config, logger, log_formatter):
|
||||
"""Process a single track through prep and finalise stages"""
|
||||
try:
|
||||
# Extract track info from CSV row
|
||||
artist = row["Artist"]
|
||||
title = row["Title"]
|
||||
guide_file = row["Mixed Audio Filename"]
|
||||
instrumental_file = row["Instrumental Audio Filename"]
|
||||
|
||||
logger.info(f"Processing track: {artist} - {title}")
|
||||
|
||||
# Initialize KaraokePrep
|
||||
kprep = KaraokePrep(
|
||||
artist=artist,
|
||||
title=title,
|
||||
input_media=guide_file,
|
||||
existing_instrumental=instrumental_file,
|
||||
style_params_json=config.style_params_json,
|
||||
log_formatter=log_formatter,
|
||||
log_level=config.log_level,
|
||||
dry_run=config.dry_run,
|
||||
)
|
||||
|
||||
# Run prep stage
|
||||
prep_result = await kprep.process()
|
||||
if not prep_result:
|
||||
raise Exception("Prep stage failed")
|
||||
|
||||
# Initialize KaraokeFinalise
|
||||
kfinalise = KaraokeFinalise(
|
||||
log_formatter=log_formatter,
|
||||
log_level=config.log_level,
|
||||
dry_run=config.dry_run,
|
||||
enable_cdg=True,
|
||||
enable_txt=True,
|
||||
brand_prefix=config.brand_prefix,
|
||||
organised_dir=config.organised_dir,
|
||||
style_params_json=config.style_params_json,
|
||||
non_interactive=True,
|
||||
)
|
||||
|
||||
# Run finalise stage
|
||||
finalise_result = kfinalise.process()
|
||||
if not finalise_result:
|
||||
raise Exception("Finalise stage failed")
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to process {artist} - {title}: {str(e)}")
|
||||
return False
|
||||
|
||||
|
||||
def update_csv_status(csv_path, row_index, new_status):
|
||||
"""Update the status of a processed row in the CSV file"""
|
||||
# Read all rows
|
||||
with open(csv_path, "r") as f:
|
||||
rows = list(csv.DictReader(f))
|
||||
|
||||
# Update status for the processed row
|
||||
rows[row_index]["Status"] = new_status
|
||||
|
||||
# Write back to CSV
|
||||
fieldnames = rows[0].keys()
|
||||
with open(csv_path, "w", newline="") as f:
|
||||
writer = csv.DictWriter(f, fieldnames=fieldnames)
|
||||
writer.writeheader()
|
||||
writer.writerows(rows)
|
||||
|
||||
|
||||
async def async_main():
|
||||
logger = logging.getLogger(__name__)
|
||||
log_handler = logging.StreamHandler()
|
||||
log_formatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
log_handler.setFormatter(log_formatter)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Process multiple karaoke tracks in bulk from a CSV file.",
|
||||
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=54),
|
||||
)
|
||||
|
||||
# Basic information
|
||||
parser.add_argument(
|
||||
"input_csv",
|
||||
help="Path to CSV file containing tracks to process. CSV should have columns: Artist,Title,Mixed Audio Filename,Instrumental Audio Filename,Status",
|
||||
)
|
||||
|
||||
package_version = pkg_resources.get_distribution("karaoke-prep").version
|
||||
parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {package_version}")
|
||||
|
||||
# Required arguments
|
||||
parser.add_argument(
|
||||
"--style_params_json",
|
||||
required=True,
|
||||
help="Path to style parameters JSON file",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--brand_prefix",
|
||||
required=True,
|
||||
help="Brand prefix for output files",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--organised_dir",
|
||||
required=True,
|
||||
help="Directory for organized output files",
|
||||
)
|
||||
|
||||
# Logging & Debugging
|
||||
parser.add_argument(
|
||||
"--log_level",
|
||||
default="info",
|
||||
help="Optional: logging level, e.g. info, debug, warning (default: %(default)s). Example: --log_level=debug",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dry_run",
|
||||
action="store_true",
|
||||
help="Optional: perform a dry run without making any changes (default: %(default)s). Example: --dry_run",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not os.path.isfile(args.input_csv):
|
||||
logger.error(f"Input CSV file not found: {args.input_csv}")
|
||||
exit(1)
|
||||
|
||||
log_level = getattr(logging, args.log_level.upper())
|
||||
logger.setLevel(log_level)
|
||||
|
||||
logger.info(f"Starting bulk processing with input CSV: {args.input_csv}")
|
||||
|
||||
# Read and process CSV
|
||||
with open(args.input_csv, "r") as f:
|
||||
reader = csv.DictReader(f)
|
||||
rows = list(reader) # Convert to list to allow multiple passes
|
||||
|
||||
for i, row in enumerate(rows):
|
||||
if row["Status"].lower() != "uploaded":
|
||||
logger.info(f"Skipping {row['Artist']} - {row['Title']} (Status: {row['Status']})")
|
||||
continue
|
||||
|
||||
logger.info(f"Starting processing of {row['Artist']} - {row['Title']}")
|
||||
|
||||
success = await process_track(row, args, logger, log_formatter)
|
||||
|
||||
if not args.dry_run:
|
||||
if success:
|
||||
update_csv_status(args.input_csv, i, "Completed")
|
||||
logger.info(f"Successfully processed {row['Artist']} - {row['Title']}")
|
||||
else:
|
||||
update_csv_status(args.input_csv, i, "Failed")
|
||||
logger.error(f"Failed to process {row['Artist']} - {row['Title']}")
|
||||
|
||||
|
||||
def main():
|
||||
# Set up logging
|
||||
logger = logging.getLogger(__name__)
|
||||
log_handler = logging.StreamHandler()
|
||||
log_formatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
log_handler.setFormatter(log_formatter)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
# Run the async main function using asyncio
|
||||
asyncio.run(async_main())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -7,6 +7,7 @@ import os
|
||||
import json
|
||||
import sys
|
||||
from karaoke_prep import KaraokePrep
|
||||
import asyncio
|
||||
|
||||
|
||||
def is_url(string):
|
||||
@@ -19,7 +20,7 @@ def is_file(string):
|
||||
return os.path.isfile(string)
|
||||
|
||||
|
||||
def main():
|
||||
async def async_main():
|
||||
logger = logging.getLogger(__name__)
|
||||
log_handler = logging.StreamHandler()
|
||||
log_formatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
@@ -160,6 +161,10 @@ def main():
|
||||
"--lyrics_title",
|
||||
help="Optional: Override the song title used for lyrics search. Example: --lyrics_title='Hey Jude'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lyrics_file",
|
||||
help="Optional: Path to a file containing lyrics to use instead of fetching from online. Example: --lyrics_file='/path/to/lyrics.txt'",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--skip_lyrics",
|
||||
action="store_true",
|
||||
@@ -256,13 +261,14 @@ def main():
|
||||
# Lyrics Configuration
|
||||
lyrics_artist=args.lyrics_artist,
|
||||
lyrics_title=args.lyrics_title,
|
||||
lyrics_file=args.lyrics_file,
|
||||
skip_lyrics=args.skip_lyrics,
|
||||
skip_transcription=args.skip_transcription,
|
||||
# Style Configuration
|
||||
style_params_json=args.style_params_json,
|
||||
)
|
||||
|
||||
tracks = kprep.process()
|
||||
tracks = await kprep.process()
|
||||
|
||||
logger.info(f"Karaoke Prep complete! Output files:")
|
||||
|
||||
@@ -303,5 +309,17 @@ def main():
|
||||
logger.info(f" Combined Instrumental: {file_path}")
|
||||
|
||||
|
||||
def main():
|
||||
# Set up logging
|
||||
logger = logging.getLogger(__name__)
|
||||
log_handler = logging.StreamHandler()
|
||||
log_formatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
log_handler.setFormatter(log_formatter)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
# Run the async main function using asyncio
|
||||
asyncio.run(async_main())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Generated
+11
-10
@@ -211,18 +211,19 @@ test-tox-coverage = ["coverage (>=5.5)"]
|
||||
|
||||
[[package]]
|
||||
name = "beautifulsoup4"
|
||||
version = "4.12.3"
|
||||
version = "4.13.0"
|
||||
description = "Screen-scraping library"
|
||||
optional = false
|
||||
python-versions = ">=3.6.0"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"},
|
||||
{file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"},
|
||||
{file = "beautifulsoup4-4.13.0-py3-none-any.whl", hash = "sha256:9c4c3dfa67aba55f6cd03769c441b21e6a369797fd6766e4b4c6b3399aae2735"},
|
||||
{file = "beautifulsoup4-4.13.0.tar.gz", hash = "sha256:b6e5afb3a2b1472c8db751a92eabf7834e5c7099f990c5e4b35f1f16b60bae64"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
soupsieve = ">1.2"
|
||||
typing-extensions = "*"
|
||||
|
||||
[package.extras]
|
||||
cchardet = ["cchardet"]
|
||||
@@ -1215,14 +1216,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "fsspec"
|
||||
version = "2024.12.0"
|
||||
version = "2025.2.0"
|
||||
description = "File-system specification"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "fsspec-2024.12.0-py3-none-any.whl", hash = "sha256:b520aed47ad9804237ff878b504267a3b0b441e97508bd6d2d8774e3db85cee2"},
|
||||
{file = "fsspec-2024.12.0.tar.gz", hash = "sha256:670700c977ed2fb51e0d9f9253177ed20cbde4a3e5c0283cc5385b5870c8533f"},
|
||||
{file = "fsspec-2025.2.0-py3-none-any.whl", hash = "sha256:9de2ad9ce1f85e1931858535bc882543171d197001a0a5eb2ddc04f1781ab95b"},
|
||||
{file = "fsspec-2025.2.0.tar.gz", hash = "sha256:1c24b16eaa0a1798afa0337aa0db9b256718ab2a89c425371f5628d22c3b6afd"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@@ -1249,7 +1250,7 @@ sftp = ["paramiko"]
|
||||
smb = ["smbprotocol"]
|
||||
ssh = ["paramiko"]
|
||||
test = ["aiohttp (!=4.0.0a0,!=4.0.0a1)", "numpy", "pytest", "pytest-asyncio (!=0.22.0)", "pytest-benchmark", "pytest-cov", "pytest-mock", "pytest-recording", "pytest-rerunfailures", "requests"]
|
||||
test-downstream = ["aiobotocore (>=2.5.4,<3.0.0)", "dask-expr", "dask[dataframe,test]", "moto[server] (>4,<5)", "pytest-timeout", "xarray"]
|
||||
test-downstream = ["aiobotocore (>=2.5.4,<3.0.0)", "dask[dataframe,test]", "moto[server] (>4,<5)", "pytest-timeout", "xarray"]
|
||||
test-full = ["adlfs", "aiohttp (!=4.0.0a0,!=4.0.0a1)", "cloudpickle", "dask", "distributed", "dropbox", "dropboxdrivefs", "fastparquet", "fusepy", "gcsfs", "jinja2", "kerchunk", "libarchive-c", "lz4", "notebook", "numpy", "ocifs", "pandas", "panel", "paramiko", "pyarrow", "pyarrow (>=1)", "pyftpdlib", "pygit2", "pytest", "pytest-asyncio (!=0.22.0)", "pytest-benchmark", "pytest-cov", "pytest-mock", "pytest-recording", "pytest-rerunfailures", "python-snappy", "requests", "smbprotocol", "tqdm", "urllib3", "zarr", "zstandard"]
|
||||
tqdm = ["tqdm"]
|
||||
|
||||
@@ -2100,14 +2101,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "lyrics-transcriber"
|
||||
version = "0.34.3"
|
||||
version = "0.36.1"
|
||||
description = "Automatically create synchronised lyrics files in ASS and MidiCo LRC formats with word-level timestamps, using Whisper and lyrics from Genius and Spotify"
|
||||
optional = false
|
||||
python-versions = "<3.13,>=3.9"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "lyrics_transcriber-0.34.3-py3-none-any.whl", hash = "sha256:cd636bf455eef626de97843b01e3a3c5b25f1415c1659fb09dd3f00a9ff59f41"},
|
||||
{file = "lyrics_transcriber-0.34.3.tar.gz", hash = "sha256:335b1b49a63dea8b5ec773a2cf85104f4cbeb432378ba7a7f0216c1d7a56cb86"},
|
||||
{file = "lyrics_transcriber-0.36.1-py3-none-any.whl", hash = "sha256:80deabcd6806ae5db045398042e04f954dd3f2bf6310bafcb9321254d16d1119"},
|
||||
{file = "lyrics_transcriber-0.36.1.tar.gz", hash = "sha256:f9e08d8dfa5b6308fe0c4bdfffb4985481f56022450a67ea2611d134e60fcaad"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-prep"
|
||||
version = "0.38.3"
|
||||
version = "0.40.0"
|
||||
description = "Prepare for karaoke video creation, by downloading audio and lyrics for a specified song or playlist from youtube and separating audio stems. After syncing, finalise the video with a title screen!"
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
@@ -42,6 +42,8 @@ poetry = "*"
|
||||
[tool.poetry.scripts]
|
||||
karaoke-prep = 'karaoke_prep.utils.prep_cli:main'
|
||||
karaoke-finalise = 'karaoke_prep.utils.finalise_cli:main'
|
||||
karaoke-auto = 'karaoke_prep.utils.auto_cli:main'
|
||||
karaoke-bulk = 'karaoke_prep.utils.bulk_cli:main'
|
||||
|
||||
[tool.black]
|
||||
line-length = 140
|
||||
|
||||
Reference in new issue
Block a user