Merge branch 'main' into feature-num2words

This commit is contained in:
agwosdz authored and GitHub committed 2024-12-15 19:57:36 -05:00
commit e65a4613f6
5 files changed
+33 -11

No files matched your search

+8
View File
@@ -132,6 +132,9 @@ _Not all options working now!_
--plot True|False >> ((default) is False)
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.0.0)
--musescore_path path to MuseScore executable
[yt-dlp]
--cookiefile File name where cookies should be read from
[device]
--force_cpu True|False >> ((default) is False) All steps will be forced to cpu
@@ -157,6 +160,11 @@ For standard use, you only need to use [opt]. All other options are optional.
-i https://www.youtube.com/watch?v=BaW_jenozKc
```
Note that if you run into a yt-dlp error such as `Sign in to confirm you’re not a bot. This helps protect our community` ([yt-dlp issue](https://github.com/yt-dlp/yt-dlp/issues/10128)) you can follow these steps:
* generate a cookies.txt file with [yt-dlp](https://github.com/yt-dlp/yt-dlp/wiki/Installation) `yt-dlp --cookies cookies.txt --cookies-from-browser firefox`
* then pass the cookies.txt to UltraSinger `--cookiefile cookies.txt`
#### UltraStar (re-pitch)
This re-pitch the audio and creates a new txt file.
+3
View File
@@ -55,6 +55,9 @@ class Settings:
# MuseScore
musescore_path = None
# yt-dlp
cookiefile = None
# UltraSinger Evaluation Configuration
test_songs_input_folder = None
cache_override_path = None
+5 -2
View File
@@ -337,7 +337,7 @@ def InitProcessData():
settings.output_folder_path,
process_data.process_data_paths.audio_output_file_path,
process_data.media_info,
) = download_from_youtube(settings.input_file_path, settings.output_folder_path)
) = download_from_youtube(settings.input_file_path, settings.output_folder_path, settings.cookiefile)
else:
# Audio File
print(f"{ULTRASINGER_HEAD} {gold_highlighted('full automatic mode')}")
@@ -652,6 +652,8 @@ def init_settings(argv: list[str]) -> Settings:
settings.keep_cache = arg
elif opt in ("--musescore_path"):
settings.musescore_path = arg
elif opt in ("--cookiefile"):
settings.cookiefile = arg
if settings.output_folder_path == "":
if settings.input_file_path.startswith("https:"):
dirname = os.getcwd()
@@ -689,8 +691,9 @@ def arg_options():
"force_whisper_cpu=",
"force_crepe_cpu=",
"format_version=",
"keep_cache",
"keep_cache=",
"musescore_path=",
"cookiefile=",
"keep_numbers="
]
return long, short
+14 -9
View File
@@ -15,10 +15,12 @@ from modules.Image.image_helper import crop_image_to_square
from modules.musicbrainz_client import get_music_infos
def get_youtube_title(url: str) -> tuple[str, str]:
def get_youtube_title(url: str, cookiefile: str = None) -> tuple[str, str]:
"""Get the title of the YouTube video"""
ydl_opts = {}
ydl_opts = {
"cookiefile": cookiefile,
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
result = ydl.extract_info(
url, download=False # We just want to extract the info
@@ -31,7 +33,7 @@ def get_youtube_title(url: str) -> tuple[str, str]:
return result["channel"].strip(), result["title"].strip()
def __download_youtube_audio(url: str, clear_filename: str, output_path: str):
def __download_youtube_audio(url: str, clear_filename: str, output_path: str, cookiefile: str = None):
"""Download audio from YouTube"""
print(f"{ULTRASINGER_HEAD} Downloading Audio")
@@ -41,18 +43,20 @@ def __download_youtube_audio(url: str, clear_filename: str, output_path: str):
"postprocessors": [
{"key": "FFmpegExtractAudio", "preferredcodec": "mp3"}
],
"cookiefile": cookiefile,
}
__start_download(ydl_opts, url)
def __download_youtube_thumbnail(url: str, clear_filename: str, output_path: str) -> str:
def __download_youtube_thumbnail(url: str, clear_filename: str, output_path: str, cookiefile: str = None) -> str:
"""Download thumbnail from YouTube"""
print(f"{ULTRASINGER_HEAD} Downloading thumbnail")
ydl_opts = {
"skip_download": True,
"writethumbnail": True,
"cookiefile": cookiefile,
}
thumbnail_url = download_and_convert_thumbnail(ydl_opts, url, clear_filename, output_path)
@@ -78,13 +82,14 @@ def download_and_convert_thumbnail(ydl_opts, url: str, clear_filename: str, outp
return ""
def __download_youtube_video(url: str, clear_filename: str, output_path: str) -> None:
def __download_youtube_video(url: str, clear_filename: str, output_path: str, cookiefile: str = None) -> None:
"""Download video from YouTube"""
print(f"{ULTRASINGER_HEAD} Downloading Video")
ydl_opts = {
"format": "bestvideo[ext=mp4]/mp4",
"outtmpl": output_path + "/" + clear_filename + ".mp4",
"cookiefile": cookiefile,
}
__start_download(ydl_opts, url)
@@ -98,9 +103,9 @@ def __start_download(ydl_opts, url: str) -> None:
raise Exception("Download failed with error: " + str(errors))
def download_from_youtube(input_file_path: str, output_folder_path: str) -> tuple[str, str, str, MediaInfo]:
def download_from_youtube(input_file_path: str, output_folder_path: str, cookiefile: str = None) -> tuple[str, str, str, MediaInfo]:
"""Download from YouTube"""
(artist, title) = get_youtube_title(input_file_path)
(artist, title) = get_youtube_title(input_file_path, cookiefile)
# Get additional data for song
(title_info, artist_info, year_info, genre_info) = get_music_infos(
@@ -116,8 +121,8 @@ def download_from_youtube(input_file_path: str, output_folder_path: str) -> tupl
song_output = os.path.join(output_folder_path, basename_without_ext)
song_output = get_unused_song_output_dir(song_output)
os_helper.create_folder(song_output)
__download_youtube_audio(input_file_path, basename_without_ext, song_output)
__download_youtube_video(input_file_path, basename_without_ext, song_output)
__download_youtube_audio(input_file_path, basename_without_ext, song_output, cookiefile)
__download_youtube_video(input_file_path, basename_without_ext, song_output, cookiefile)
thumbnail_url = __download_youtube_thumbnail(
input_file_path, basename_without_ext, song_output
)
+3
View File
@@ -56,6 +56,9 @@ def print_help() -> None:
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.0.0)
--musescore_path path to MuseScore executable
[yt-dlp]
--cookiefile File name where cookies should be read from and dumped to.
[device]
--force_cpu True|False >> ((default) is False) All steps will be forced to cpu
--force_whisper_cpu True|False >> ((default) is False) Only whisper will be forced to cpu