mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge pull request #193 from rakuri255/Add-VideoURL
Added VideoURL and bump format version to 1.2.0
This commit is contained in:
10 files changed
+41
-21
No files matched your search
@@ -103,11 +103,6 @@ _Not all options working now!_
|
||||
## if INPUT is ultrastar.txt ##
|
||||
default Creates all
|
||||
|
||||
# Single selection is in progress, you currently getting all!
|
||||
(-r repitch Ultrastar.txt (input has to be audio)) # In Progress
|
||||
(-p Check pitch of Ultrastar.txt input) # In Progress
|
||||
(-m Create midi file) # In Progress
|
||||
|
||||
[transcription]
|
||||
# Default is whisper
|
||||
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2)
|
||||
@@ -130,7 +125,7 @@ _Not all options working now!_
|
||||
--create_audio_chunks True|False >> ((default) is False)
|
||||
--keep_cache Keep cache folder after generation > True|False >> ((default) is False)
|
||||
--plot Create a pitch plot > True|False >> ((default) is False)
|
||||
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.1.0)
|
||||
--format_version 0.3.0|1.0.0|1.1.0|1.2.0 >> ((default) is 1.2.0)
|
||||
--musescore_path path to MuseScore executable
|
||||
--keep_numbers Transcribe numbers as digits and not words > True|False >> ((default) is False)
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ class TestCreateUltrastarTxt(unittest.TestCase):
|
||||
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
|
||||
ultrastar_file_output)
|
||||
|
||||
class_under_test.version = "1.2.0"
|
||||
expected_calls = self.default_values(class_under_test, class_under_test.version)
|
||||
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
|
||||
ultrastar_file_output)
|
||||
|
||||
def test_create_ultrastar_txt_from_automation_full_values(self):
|
||||
# Arrange
|
||||
bpm, midi_segments, ultrastar_file_output = self.arrange()
|
||||
@@ -44,6 +49,7 @@ class TestCreateUltrastarTxt(unittest.TestCase):
|
||||
class_under_test.tags = "pop, rock"
|
||||
class_under_test.cover = "cover [CO].jpg"
|
||||
class_under_test.video = "video.mp4"
|
||||
class_under_test.videoUrl = "https://xyz.com/video"
|
||||
class_under_test.mp3 = "music.mp3"
|
||||
class_under_test.audio = "music.mp3"
|
||||
class_under_test.vocals = "vocals.mp3"
|
||||
@@ -66,6 +72,11 @@ class TestCreateUltrastarTxt(unittest.TestCase):
|
||||
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
|
||||
ultrastar_file_output)
|
||||
|
||||
class_under_test.version = "1.2.0"
|
||||
expected_calls = self.full_values(class_under_test, class_under_test.version)
|
||||
self.act_and_assert(bpm, class_under_test, expected_calls, midi_segments,
|
||||
ultrastar_file_output)
|
||||
|
||||
def arrange(self) -> tuple[int, list[MidiSegment], str]:
|
||||
midi_segments = [
|
||||
MidiSegment(note="C#3", start=0.5, end=2.5, word="UltraSinger "),
|
||||
@@ -105,6 +116,9 @@ class TestCreateUltrastarTxt(unittest.TestCase):
|
||||
expected_calls += [
|
||||
f"#{UltrastarTxtTag.VIDEO}:{default_ultrastar_class.video}\n"
|
||||
]
|
||||
if version.parse(ver) >= version.parse("1.2.0"):
|
||||
if default_ultrastar_class.videoUrl is not None:
|
||||
expected_calls += [f"#{UltrastarTxtTag.VIDEOURL}:{default_ultrastar_class.videoUrl}\n"]
|
||||
expected_calls += [
|
||||
f"#{UltrastarTxtTag.BPM}:390.0\n",
|
||||
f"#{UltrastarTxtTag.GAP}:500\n",
|
||||
@@ -136,6 +150,8 @@ class TestCreateUltrastarTxt(unittest.TestCase):
|
||||
expected_calls.append(f"#{UltrastarTxtTag.INSTRUMENTAL}:{default_ultrastar_class.instrumental}\n")
|
||||
expected_calls.append(f"#{UltrastarTxtTag.TAGS}:{default_ultrastar_class.tags}\n")
|
||||
expected_calls.append(f"#{UltrastarTxtTag.VIDEO}:{default_ultrastar_class.video}\n")
|
||||
if version.parse(ver) >= version.parse("1.2.0"):
|
||||
expected_calls.append(f"#{UltrastarTxtTag.VIDEOURL}:{default_ultrastar_class.videoUrl}\n")
|
||||
expected_calls.append(f"#{UltrastarTxtTag.BPM}:390.0\n")
|
||||
expected_calls.append(f"#{UltrastarTxtTag.GAP}:500\n")
|
||||
expected_calls.append(f"#{UltrastarTxtTag.CREATOR}:{default_ultrastar_class.creator}\n")
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ class Settings:
|
||||
output_folder_path = ""
|
||||
|
||||
language = None
|
||||
format_version = FormatVersion.V1_1_0
|
||||
format_version = FormatVersion.V1_2_0
|
||||
|
||||
# Demucs
|
||||
demucs_model = DemucsModel.HTDEMUCS # htdemucs|htdemucs_ft|htdemucs_6s|hdemucs_mmi|mdx|mdx_extra|mdx_q|mdx_extra_q|SIG
|
||||
|
||||
+3
-1
@@ -337,7 +337,7 @@ def InitProcessData():
|
||||
process_data.basename,
|
||||
settings.output_folder_path,
|
||||
process_data.process_data_paths.audio_output_file_path,
|
||||
process_data.media_info,
|
||||
process_data.media_info
|
||||
) = download_from_youtube(settings.input_file_path, settings.output_folder_path, settings.cookiefile)
|
||||
else:
|
||||
# Audio File
|
||||
@@ -646,6 +646,8 @@ def init_settings(argv: list[str]) -> Settings:
|
||||
settings.format_version = FormatVersion.V1_0_0
|
||||
elif arg == FormatVersion.V1_1_0.value:
|
||||
settings.format_version = FormatVersion.V1_1_0
|
||||
elif arg == FormatVersion.V1_2_0.value:
|
||||
settings.format_version = FormatVersion.V1_2_0
|
||||
else:
|
||||
print(
|
||||
f"{ULTRASINGER_HEAD} {red_highlighted('Error: Format version')} {blue_highlighted(arg)} {red_highlighted('is not supported.')}"
|
||||
|
||||
@@ -103,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, cookiefile: str = None) -> tuple[str, str, str, MediaInfo]:
|
||||
def download_from_youtube(input_url: str, output_folder_path: str, cookiefile: str = None) -> tuple[str, str, str, MediaInfo]:
|
||||
"""Download from YouTube"""
|
||||
(artist, title) = get_youtube_title(input_file_path, cookiefile)
|
||||
(artist, title) = get_youtube_title(input_url, cookiefile)
|
||||
|
||||
# Get additional data for song
|
||||
(title_info, artist_info, year_info, genre_info) = get_music_infos(
|
||||
@@ -121,10 +121,10 @@ def download_from_youtube(input_file_path: str, output_folder_path: str, cookief
|
||||
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, cookiefile)
|
||||
__download_youtube_video(input_file_path, basename_without_ext, song_output, cookiefile)
|
||||
__download_youtube_audio(input_url, basename_without_ext, song_output, cookiefile)
|
||||
__download_youtube_video(input_url, basename_without_ext, song_output, cookiefile)
|
||||
thumbnail_url = __download_youtube_thumbnail(
|
||||
input_file_path, basename_without_ext, song_output
|
||||
input_url, basename_without_ext, song_output
|
||||
)
|
||||
audio_file_path = os.path.join(song_output, basename)
|
||||
real_bpm = get_bpm_from_file(audio_file_path)
|
||||
@@ -133,5 +133,5 @@ def download_from_youtube(input_file_path: str, output_folder_path: str, cookief
|
||||
song_output,
|
||||
audio_file_path,
|
||||
MediaInfo(artist=artist, title=title, year=year_info, genre=genre_info, bpm=real_bpm,
|
||||
youtube_thumbnail_url=thumbnail_url),
|
||||
youtube_thumbnail_url=thumbnail_url, youtube_video_url=input_url),
|
||||
)
|
||||
@@ -24,6 +24,7 @@ class MediaInfo:
|
||||
genre: Optional[str] = None
|
||||
language: Optional[str] = None
|
||||
youtube_thumbnail_url: Optional[str] = None
|
||||
youtube_video_url: Optional[str] = None
|
||||
|
||||
@dataclass
|
||||
class ProcessData:
|
||||
|
||||
@@ -86,6 +86,8 @@ def create_ultrastar_txt_from_automation(
|
||||
ultrastar_txt.year = extract_year(media_info.year)
|
||||
if media_info.genre is not None:
|
||||
ultrastar_txt.genre = format_separated_string(media_info.genre)
|
||||
if media_info.youtube_video_url is not None:
|
||||
ultrastar_txt.videoUrl = media_info.youtube_video_url
|
||||
|
||||
ultrastar_file_output_path = os.path.join(song_folder_output_path, basename + ".txt")
|
||||
create_ultrastar_txt(
|
||||
@@ -106,6 +108,9 @@ def create_ultrastar_txt_from_automation(
|
||||
ultrastar_txt,
|
||||
media_info.bpm,
|
||||
)
|
||||
if version.parse(format_version.value) < version.parse(FormatVersion.V1_2_0.value):
|
||||
ultrastar_txt.videoUrl = media_info.youtube_video_url
|
||||
|
||||
return ultrastar_file_output_path
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ class UltrastarTxtTag(str, Enum):
|
||||
INSTRUMENTAL = 'INSTRUMENTAL' # Instrumental only audio
|
||||
TAGS = 'TAGS' # Tags for the song. Can be used for filtering
|
||||
|
||||
# 1.2.0
|
||||
VIDEOURL = 'VIDEOURL' # URL to the video file
|
||||
|
||||
# Unused 0.2.0
|
||||
EDITION = 'EDITION' # Multi-language support since v1.1.0
|
||||
START = 'START'
|
||||
@@ -59,7 +62,6 @@ class UltrastarTxtTag(str, Enum):
|
||||
AUDIOURL = 'AUDIOURL' # URL to the audio file
|
||||
COVERURL = 'COVERURL' # URL to the cover file
|
||||
BACKGROUNDURL = 'BACKGROUNDURL' # URL to the background file
|
||||
VIDEOURL = 'VIDEOURL' # URL to the video file
|
||||
|
||||
# (Unused) New in (unreleased) 2.0.0
|
||||
MEDLEYSTART = 'MEDLEYSTART' # Rename of MEDLEYSTARTBEAT
|
||||
@@ -121,6 +123,7 @@ class UltrastarTxtValue:
|
||||
mp3 = ""
|
||||
audio = ""
|
||||
video = None
|
||||
videoUrl = None
|
||||
videoGap = None
|
||||
gap = ""
|
||||
bpm = ""
|
||||
|
||||
@@ -79,6 +79,9 @@ def create_ultrastar_txt(
|
||||
file.write(f"#{UltrastarTxtTag.VIDEO}:{ultrastar_class.video}\n")
|
||||
if ultrastar_class.videoGap is not None:
|
||||
file.write(f"#{UltrastarTxtTag.VIDEOGAP}:{ultrastar_class.videoGap}\n")
|
||||
if version.parse(ultrastar_class.version) >= version.parse("1.2.0"):
|
||||
if ultrastar_class.videoUrl is not None:
|
||||
file.write(f"#{UltrastarTxtTag.VIDEOURL}:{ultrastar_class.videoUrl}\n")
|
||||
file.write(f"#{UltrastarTxtTag.BPM}:{round(ultrastar_bpm, 2)}\n") # not the real BPM!
|
||||
file.write(f"#{UltrastarTxtTag.GAP}:{int(gap * 1000)}\n")
|
||||
file.write(f"#{UltrastarTxtTag.CREATOR}:{ultrastar_class.creator}\n")
|
||||
|
||||
@@ -26,11 +26,6 @@ def print_help() -> None:
|
||||
## INPUT is ultrastar.txt ##
|
||||
default Creates all
|
||||
|
||||
# Single selection is in progress, you currently getting all!
|
||||
(-r repitch Ultrastar.txt (input has to be audio)) # In Progress
|
||||
(-p Check pitch of Ultrastar.txt input) # In Progress
|
||||
(-m Create midi file) # In Progress
|
||||
|
||||
[transcription]
|
||||
# Default is whisper
|
||||
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2)
|
||||
@@ -53,7 +48,7 @@ def print_help() -> None:
|
||||
--create_audio_chunks True|False >> ((default) is False)
|
||||
--keep_cache Keep cache folder after generation > True|False >> ((default) is False)
|
||||
--plot Create a pitch plot > True|False >> ((default) is False)
|
||||
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.1.0)
|
||||
--format_version 0.3.0|1.0.0|1.1.0|1.2.0 >> ((default) is 1.2.0)
|
||||
--musescore_path path to MuseScore executable
|
||||
|
||||
[yt-dlp]
|
||||
|
||||
Reference in new issue
Block a user