Package: karaoke-prep
Karaoke Prep 🎶Prepare for karaoke video creation, by downloading audio from YouTube and lyrics from Genius for a given song.This was created to make it easier for me to prepare the source audio, lyrics and instrumental audio so I can then do the actual karaoke creation in focus mode without internet.FeaturesAudio Fetching: Automatically downloads audio in WAV format for the YouTube URL provided (or searches for the song/artist name and fetches the top result).Lyrics Fetching: Automatically fetches song lyrics from Genius.com usingLyricsGenius.Audio Separation: Separates the downloaded audio into instrumental and vocal tracks, usingaudio-separator.Multiple Audio Models: Runs audio separation with 2 different models (by default,UVR_MDXNET_KARA_2andUVR-MDX-NET-Inst_HQ_3) to give you options for the backing track.Easy Configuration: Control the tool's behavior using command-line arguments.Organized Outputs: Creates structured output directories for easy access to generated tracks and lyrics.Internet First: Completes operations which require internet first, in case user is preparing last-minute before a period of being offline!Flexible Input: provide just a YouTube URL, just an artist and title, or both.Playlist Processing: Capable of processing an entire YouTube playlist, extracting audio and lyrics for each track.Easy Finalisation: After manually performing your sync (e.g. usingMidiCo), runkaraoke-finaliseto remux and add your title screen!Installation 🛠️You'll need Python version 3.9, 3.10 or 3.11 (newer versions aren't supported by PyTorch or ONNX Runtime yet).You can install Karaoke Prep using pip:pip install karaoke-prepYou'll then also need to install a version ofaudio-separatorfor your hardware:Mac with Apple Silicon:pip install audio-separator[silicon]Linux/Windows with CUDA GPU:pip install audio-separator[gpu]Anything else:pip install audio-separator[cpu]Install PyTorch with CUDA supportIf you're trying to use CUDA for GPU acceleration, you'll also need to ensure the version of PyTorch you have installed is compatible with the CUDA version you have installed.While PyTorch should get installed as a dependency ofkaraoke-prepanyway, you may need to install PyTorch for your CUDA version by running the installation command provided by the official install wizard:https://pytorch.org/get-started/locally/UnicodeEncodeErrorIf you encounter this error:UnicodeEncodeError: 'charmap' codec can't encode characterTry setting the Python I/O encoding in your environment:export PYTHONIOENCODING=utf-8Command-line newbie?If you aren't sure whatpipis or how to use the command line, here are some YouTube tutorials which will probably help:Install Python on Windows:https://www.youtube.com/watch?v=YKSpANU8jPECommand Line basics Windows:https://www.youtube.com/watch?v=MBBWVgE0ewkInstall Python on Mac:https://www.youtube.com/watch?v=3-sPfR4JEQ8Command Line basics Mac:https://www.youtube.com/watch?v=FfT8OfMpARMKaraoke production guide using karaoke-prep and MidiCoRunkaraoke-prep <Artist> <Title>to fetch and prep the files aboveWait for it to output at least the WAV file and lyrics (you can leave it running in the background while you sync)Open the WAV file in MidiCo:(YouTube xxxxxxxxxxx).wavCopy/paste the lyrics into MidiCo:(Lyrics Processed).txtPerform the lyrics sync (here's avideoshowing me doing it) in MidiCoRender the video to 4k using the MidiCo "Export Movie" feature, saving it asArtist - Title (Karaoke).movin the same folderRunkaraoke-finaliseto remux the instrumental audio and join the title clip to the startUpload the resultingArtist - Title (Final Karaoke).mp4video to YouTube!Here's mytutorial video with verbal explanationof the whole process, and here's anormal speed demoof me doing it (8 minutes total for a single track).Usage 🚀Command Line Interface (CLI)You can use Karaoke Prep via the command line:usage:karaoke-prep[-h][-v][--log_levelLOG_LEVEL][--model_nameMODEL_NAME][--model_file_dirMODEL_FILE_DIR][--output_dirOUTPUT_DIR][--use_cuda][--use_coreml][--denoiseDENOISE][--normalizeNORMALIZE][--create_track_subfolders][artist][title][url]Fetchaudioandlyricsforaspecifiedsong,topreparekaraokevideocreation.

positionalarguments:args[YouTubevideoorplaylistURL][Artist][Title]ofsongtoprep.IfURLisprovided,ArtistandTitleareoptionalbutincreasechanceoffetchingthecorrectlyrics.IfArtistandTitleareprovidedwithnoURL,thetopYouTubesearchresultwillbefetched.

options:-h,--helpshowthishelpmessageandexit-v,--versionshowprogram'sversionnumberandexit--log_levelLOG_LEVELOptional:logginglevel,e.g.info,debug,warning(default:info).Example:--log_level=debug--model_nameMODEL_NAMEOptional:modelnametobeusedforseparation(default:UVR_MDXNET_KARA_2).Example:--model_name=UVR-MDX-NET-Inst_HQ_3--model_file_dirMODEL_FILE_DIROptional:modelfilesdirectory(default:/tmp/audio-separator-models/).Example:--model_file_dir=/app/models--output_dirOUTPUT_DIROptional:directorytowriteoutputfiles(default:<currentdir>).Example:--output_dir=/app/karaoke--use_cudaOptional:useNvidiaGPUwithCUDAforseparation(default:False).Example:--use_cuda=true--use_coremlOptional:useAppleSiliconGPUwithCoreMLforseparation(default:False).Example:--use_coreml=true--denoiseDENOISEOptional:enableordisabledenoisingduringseparation(default:True).Example:--denoise=False--normalizeNORMALIZEOptional:enableordisablenormalizationduringseparation(default:True).Example:--normalize=False--no_track_subfoldersOptional:doNOTcreateanamedsubfolderforeachtrack.Example:--no_track_subfolders--intro_background_colorINTRO_BACKGROUND_COLOROptional:Backgroundcolorforintrovideo(default:black).Example:--intro_background_color=#123456--intro_background_imageINTRO_BACKGROUND_IMAGEOptional:Pathtobackgroundimageforintrovideo.Overridesbackgroundcolorifprovided.Example:--intro_background_image=path/to/image.jpg--intro_fontINTRO_FONTOptional:Fontfileforintrovideo(default:Avenir-Next-Bold).Example:--intro_font=AvenirNext-Bold.ttf--intro_artist_colorINTRO_ARTIST_COLOROptional:Fontcolorforintrovideoartisttext(default:#ff7acc). Example: --intro_artist_color=#123456--intro_title_colorINTRO_TITLE_COLOROptional:Fontcolorforintrovideotitletext(default:#ffdf6b). Example: --intro_title_color=#123456⭐ YouTube URL with Artist and TitleFor the most consistent results, provide a specific YouTube URL along with the artist and title like so:karaoke-prep "https://www.youtube.com/watch?v=YOUR_VIDEO_ID" "The Fray" "Never Say Never"Artist and Title OnlyIf you don't have a specific YouTube URL, just provide the artist and title. Karaoke Prep will search for and download the top YouTube result.karaoke-prep "The Fray" "Never Say Never"Only YouTube URLThis will process the video at the given URL,guessing the artist and title from the YouTube title.
⚠️ Be aware the downloaded lyrics may be incorrect if the video title doesn't match the standard "Artist - Title" format.karaoke-prep "https://www.youtube.com/watch?v=YOUR_VIDEO_ID"YouTube Playlist URLTo process a playlist, just provide the playlist URL. The script will process every video in the playlist.
⚠️ Be aware the downloadedlyricsfor each track may be incorrect if the video titles don't match the standard "Artist - Title" format.karaoke-prep "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"Files produced by karaoke-prep and what to do with themAfter runningkaraoke-prepyou should have the following 11 files, grouped into folder(s) for each track:Artist - Title (YouTube xxxxxxxxxxx).webmOriginal unmodified video, fetched from YouTube in the highest quality available (may not always be WebM)You probably don't need this unless you're creating a custom requestArtist - Title (YouTube xxxxxxxxxxx).pngA still image taken from 30 seconds into the video, in case that's useful for a custom backgroundYou probably don't need this unless you're creating a custom requestArtist - Title (YouTube xxxxxxxxxxx).wavUnmodified audio from the YouTube video, converted to WAV format for compatibilityYou should open this in MidiCo to begin syncing lyrics to make your karaoke video.Artist - Title (Lyrics).txtUnmodified lyrics fetched from genius.com based on the artist/title providedDepending on the song, may have lines which are too long for one karaoke screenArtist - Title (Lyrics Processed).txtLyrics from genius, split into lines no longer than 40 charactersYou should open this and copy/paste the text into the MidiCo lyrics editorArtist - Title (Vocals UVR-MDX-NET-Inst_HQ_3).mp3Vocal track from the audio, separated using the UVR Inst_HQ_3 model.You probably don't need this unless you're trying to tweak the backing trackArtist - Title (Vocals UVR_MDXNET_KARA_2).mp3Vocal track from the audio, separated using the UVR KARA_2 model.You probably don't need this unless you're trying to tweak the backing trackArtist - Title (Instrumental UVR-MDX-NET-Inst_HQ_3).mp3Instrumental track from the audio, separated using the UVR Inst_HQ_3 model.This is typically a safe bet for the instrumental track but will not include any backing vocals.Artist - Title (Instrumental UVR_MDXNET_KARA_2).mp3Instrumental track from the audio, separated using the UVR KARA_2 model.This is the default choice for the finalisation step below as it usually does a good job of keeping backing vocals. However for some songs it includes far too much or is kinda glitchy, so you should check it before finalising and make a judgement call about using this vs. the Inst_HQ_3 one.Artist - Title (Title).pngTitle screen static image; if you specify your own background image, font, color etc. this should give you a convenient way to add a title screen to the start of your video.Artist - Title (Title).mov5 second video clip version of the title screen image, ready to be joined by the finalisation step.Finalisation 🎥After completing your manual sync process and rendering yourArtist - Title (Karaoke).movfile (still using the original audio!) into the same folder, you can now runkaraoke-finalise.This will output some additional files:Artist - Title (Karaoke).movKaraoke video without title screen, remuxed to use the instrumental audioArtist - Title (With Vocals).movKaraoke video without title screen, using the original audio (useful for practicing!)Artist - Title (Final Karaoke).mp4Final karaoke video with 5 second title screen intro, instrumental audio and converted to MP4 for compatibility and reduced file size. Upload this to YouTube!Requirements 📋Python >= 3.9Libraries: onnx, onnxruntime, numpy, soundfile, librosa, torch, wget, sixDeveloping LocallyThis project uses Poetry for dependency management and packaging. Follow these steps to setup a local development environment:PrerequisitesMake sure you have Python 3.9 or newer installed on your machine.Install Poetry by following the installation guide here.Clone the RepositoryClone the repository to your local machine:git clone https://github.com/YOUR_USERNAME/karaoke-prep.git
cd karaoke-prepReplace YOUR_USERNAME with your GitHub username if you've forked the repository, or use the main repository URL if you have the permissions.Install DependenciesRun the following command to install the project dependencies:poetry installActivate the Virtual EnvironmentTo activate the virtual environment, use the following command:poetry shellRunning the Command-Line Interface LocallyYou can run the CLI command directly within the virtual environment. For example:karaoke-prep 1Deactivate the Virtual EnvironmentOnce you are done with your development work, you can exit the virtual environment by simply typing:exitBuilding the PackageTo build the package for distribution, use the following command:poetry buildThis will generate the distribution packages in the dist directory - but for now only @beveradb will be able to publish to PyPI.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 likelyLicense 📄This project is licensed under the MITLicense.Please Note:If you choose to integrate this project into some other project using the default model or any other model trained as part of theUVRproject, please honor the MIT license by providing credit to UVR and its developers!Credits 🙏Anjok07- Author ofUltimate Vocal Remover GUI, which was essential for the creation ofaudio-separator! Thank you!Contact 💌For questions or feedback, please raise an issue or reach out to @beveradb (Andrew Beveridge) directly.