diff --git a/Dockerfile b/Dockerfile index ecc9714..01e4f9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,13 @@ FROM nvidia/cuda:12.8.1-runtime-ubuntu22.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=UTC -# Install Python 3.12 from deadsnakes PPA +# Install Python 3.12 from deadsnakes PPA and build tools RUN apt-get update \ && apt-get install -y software-properties-common \ && add-apt-repository ppa:deadsnakes/ppa -y \ && apt-get update \ && apt-get install -y git python3.12 python3.12-venv python3.12-dev ffmpeg curl tzdata \ + build-essential gcc g++ make \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/src/UltraSinger.py b/src/UltraSinger.py index e518f5c..5863dd2 100644 --- a/src/UltraSinger.py +++ b/src/UltraSinger.py @@ -517,14 +517,14 @@ def CreateUltraStarTxt(process_data: ProcessData): # Move instrumental and vocals if settings.create_karaoke and version.parse(settings.format_version.value) < version.parse( FormatVersion.V1_1_0.value): - karaoke_output_path = os.path.join(settings.output_folder_path, process_data.basename + " [Karaoke].m4a") + karaoke_output_path = os.path.join(settings.output_folder_path, process_data.basename + " [Karaoke]." + process_data.media_info.audio_extension) convert_wav_to_mp3(process_data.process_data_paths.instrumental_audio_file_path, karaoke_output_path) if version.parse(settings.format_version.value) >= version.parse(FormatVersion.V1_1_0.value): instrumental_output_path = os.path.join(settings.output_folder_path, - process_data.basename + " [Instrumental].m4a") + process_data.basename + " [Instrumental]." + process_data.media_info.audio_extension) convert_wav_to_mp3(process_data.process_data_paths.instrumental_audio_file_path, instrumental_output_path) - vocals_output_path = os.path.join(settings.output_folder_path, process_data.basename + " [Vocals].m4a") + vocals_output_path = os.path.join(settings.output_folder_path, process_data.basename + " [Vocals]." + process_data.media_info.audio_extension) convert_wav_to_mp3(process_data.process_data_paths.vocals_audio_file_path, vocals_output_path) # Create Ultrastar txt @@ -663,12 +663,14 @@ def infos_from_audio_video_input_file() -> tuple[str, str, str, MediaInfo]: os_helper.copy(settings.input_file_path, video_with_audio_path) # Separate audio and video - ultrastar_audio_input_path, final_video_path = separate_audio_video( + ultrastar_audio_input_path, final_video_path, audio_ext, video_ext = separate_audio_video( video_with_audio_path, basename_without_ext, song_folder_output_path ) else: # Audio file basename_with_ext = f"{basename_without_ext}{extension}" + audio_ext = extension + video_ext = None os_helper.copy(settings.input_file_path, song_folder_output_path) os_helper.rename( os.path.join(song_folder_output_path, os.path.basename(settings.input_file_path)), @@ -692,6 +694,8 @@ def infos_from_audio_video_input_file() -> tuple[str, str, str, MediaInfo]: genre=song_info.genres, bpm=real_bpm, cover_url=song_info.cover_url, + audio_extension=audio_ext, + video_extension=video_ext ), ) diff --git a/src/modules/Audio/key_detector.py b/src/modules/Audio/key_detector.py index b9c98d8..bc5b008 100644 --- a/src/modules/Audio/key_detector.py +++ b/src/modules/Audio/key_detector.py @@ -94,7 +94,6 @@ def quantize_note_to_key(note: str, allowed_notes: set[str]) -> str: Returns: Quantized note name """ - print(f"{ULTRASINGER_HEAD} Quantizing note {blue_highlighted(note)} to key with allowed notes") # Parse note and octave if len(note) == 0: return note diff --git a/src/modules/Audio/youtube.py b/src/modules/Audio/youtube.py index 8e91980..cd3dfaf 100644 --- a/src/modules/Audio/youtube.py +++ b/src/modules/Audio/youtube.py @@ -104,7 +104,7 @@ def download_from_youtube(input_url: str, output_folder_path: str, cookiefile: s video_with_audio_path = os.path.join(song_output, f"{basename_without_ext}.{video_ext}") # Separate audio and video - audio_file_path, final_video_path = separate_audio_video( + audio_file_path, final_video_path, audio_ext, video_ext = separate_audio_video( video_with_audio_path, basename_without_ext, song_output ) @@ -129,5 +129,7 @@ def download_from_youtube(input_url: str, output_folder_path: str, cookiefile: s bpm=real_bpm, cover_url=cover_url, video_url=input_url, + audio_extension=audio_ext, + video_extension=video_ext ), ) diff --git a/src/modules/Midi/midi_creator.py b/src/modules/Midi/midi_creator.py index a89f1ca..97446e1 100644 --- a/src/modules/Midi/midi_creator.py +++ b/src/modules/Midi/midi_creator.py @@ -17,7 +17,7 @@ from modules.console_colors import ( from modules.Ultrastar.ultrastar_txt import UltrastarTxtValue from modules.Pitcher.pitched_data import PitchedData from modules.Pitcher.pitched_data_helper import get_frequencies_with_high_confidence - +from modules.Audio.key_detector import quantize_note_to_key def create_midi_instrument(midi_segments: list[MidiSegment]) -> object: """Converts an Ultrastar data to a midi instrument""" @@ -145,7 +145,6 @@ def create_midi_note_from_pitched_data(start_time: float, end_time: float, pitch note = most_frequent(notes)[0][0] if allowed_notes is not None: - from modules.Audio.key_detector import quantize_note_to_key note = quantize_note_to_key(note, allowed_notes) return MidiSegment(note, start_time, end_time, word) diff --git a/src/modules/ProcessData.py b/src/modules/ProcessData.py index bb84b7e..4be775a 100644 --- a/src/modules/ProcessData.py +++ b/src/modules/ProcessData.py @@ -26,6 +26,8 @@ class MediaInfo: cover_url: Optional[str] = None video_url: Optional[str] = None music_key: Optional[str] = None # (e.g., "C major", "A minor") + video_extension: Optional[str] = None # (e.g., "mp4", "mkv") + audio_extension: Optional[str] = None # (e.g., "mp3", "m4a") @dataclass class ProcessData: diff --git a/src/modules/Ultrastar/coverter/ultrastar_txt_converter.py b/src/modules/Ultrastar/coverter/ultrastar_txt_converter.py index ff94f4b..93f0381 100644 --- a/src/modules/Ultrastar/coverter/ultrastar_txt_converter.py +++ b/src/modules/Ultrastar/coverter/ultrastar_txt_converter.py @@ -66,11 +66,11 @@ def create_ultrastar_txt_from_automation( ultrastar_txt = UltrastarTxtValue() ultrastar_txt.version = format_version.value - ultrastar_txt.mp3 = basename + ".m4a" - ultrastar_txt.audio = basename + ".m4a" - ultrastar_txt.vocals = basename + " [Vocals].m4a" - ultrastar_txt.instrumental = basename + " [Instrumental].m4a" - ultrastar_txt.video = basename + ".mp4" + ultrastar_txt.mp3 = basename + "." + media_info.audio_extension + ultrastar_txt.audio = basename + "." + media_info.audio_extension + ultrastar_txt.vocals = basename + " [Vocals]." + media_info.audio_extension + ultrastar_txt.instrumental = basename + " [Instrumental]." + media_info.audio_extension + ultrastar_txt.video = basename + "." + media_info.video_extension ultrastar_txt.language = media_info.language cover = basename + " [CO].jpg" ultrastar_txt.cover = ( @@ -103,7 +103,7 @@ def create_ultrastar_txt_from_automation( if create_karaoke and version.parse(format_version.value) < version.parse(FormatVersion.V1_1_0.value): title = basename + " [Karaoke]" ultrastar_txt.title = title - ultrastar_txt.mp3 = title + ".m4a" + ultrastar_txt.mp3 = title + "." + media_info.audio_extension karaoke_output_path = os.path.join(song_folder_output_path, title) karaoke_txt_output_path = karaoke_output_path + ".txt" create_ultrastar_txt( diff --git a/src/modules/ffmpeg_helper.py b/src/modules/ffmpeg_helper.py index d4017ad..52c94fb 100644 --- a/src/modules/ffmpeg_helper.py +++ b/src/modules/ffmpeg_helper.py @@ -135,7 +135,7 @@ def get_audio_codec_and_extension(video_file_path: str) -> str: return "wav" -def separate_audio_video(video_with_audio_path: str, basename_without_ext: str, output_folder: str) -> tuple[str, str]: +def separate_audio_video(video_with_audio_path: str, basename_without_ext: str, output_folder: str) -> tuple[str, str, str, str]: """ Separate audio and video from a video file. Automatically detects the audio codec and uses the appropriate file extension. @@ -163,5 +163,5 @@ def separate_audio_video(video_with_audio_path: str, basename_without_ext: str, final_video_path = os.path.join(output_folder, f"{basename_without_ext}{video_ext}") os.rename(video_only_path, final_video_path) - return audio_file_path, final_video_path + return audio_file_path, final_video_path, audio_ext, video_ext