Merge pull request #192 from agwosdz/bug_PDF_error

Added error handling to PDF sheet generation
This commit is contained in:
Vadim Rangnau authored and GitHub committed 2024-12-18 21:01:25 +01:00
commit 26558b6d89
4 files changed
+26 -17

No files matched your search

+7 -6
View File
@@ -110,7 +110,7 @@ _Not all options working now!_
[transcription]
# Default is whisper
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2)
English-only model > tiny.en|base.en|small.en|medium.en
--whisper_align_model Use other languages model for Whisper provided from huggingface.co
--language Override the language detected by whisper, does not affect transcription but steps after transcription
@@ -123,15 +123,16 @@ _Not all options working now!_
--crepe_step_size unit is miliseconds >> ((default) is 10)
[extra]
--hyphenation True|False >> ((default) is True)
--disable_separation True|False >> ((default) is False)
--hyphenation Use automatic hyphenation > True|False >> ((default) is True)
--disable_separation Disable track separation > True|False >> ((default) is False)
--disable_karaoke True|False >> ((default) is False)
--ignore_audio True|False >> ((default) is False)
--create_audio_chunks True|False >> ((default) is False)
--keep_cache True|False >> ((default) is False)
--plot True|False >> ((default) is False)
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.0.0)
--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)
--musescore_path path to MuseScore executable
--keep_numbers Transcribe numbers as digits and not words > True|False >> ((default) is False)
[yt-dlp]
--cookiefile File name where cookies should be read from
+1
View File
@@ -28,6 +28,7 @@ from modules.console_colors import (
gold_highlighted,
red_highlighted,
green_highlighted,
cyan_highlighted
)
from modules.Midi.midi_creator import (
create_midi_segments_from_transcribed_data,
+6 -6
View File
@@ -33,7 +33,7 @@ def print_help() -> None:
[transcription]
# Default is whisper
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2
--whisper Multilingual model > tiny|base|small|medium|large-v1|large-v2 >> ((default) is large-v2)
English-only model > tiny.en|base.en|small.en|medium.en
--whisper_align_model Use other languages model for Whisper provided from huggingface.co
--language Override the language detected by whisper, does not affect transcription but steps after transcription
@@ -47,13 +47,13 @@ def print_help() -> None:
--crepe_step_size unit is miliseconds >> ((default) is 10)
[extra]
--hyphenation True|False >> ((default) is True)
--disable_separation True|False >> ((default) is False)
--hyphenation Use automatic hyphenation > True|False >> ((default) is True)
--disable_separation Disable track separation > True|False >> ((default) is False)
--disable_karaoke True|False >> ((default) is False)
--create_audio_chunks True|False >> ((default) is False)
--keep_cache True|False >> ((default) is False)
--plot True|False >> ((default) is False)
--format_version 0.3.0|1.0.0|1.1.0 >> ((default) is 1.0.0)
--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)
--musescore_path path to MuseScore executable
[yt-dlp]
+12 -5
View File
@@ -41,11 +41,18 @@ def create_sheet(midi_segments: list[MidiSegment],
success = set_environment_variables(musescore_path)
if not success:
return
s = stream.Stream()
add_metadata_to_stream(s, media_info.artist, media_info.title, int(media_info.bpm))
add_midi_segments_to_stream(s, midi_segments)
export_stream_to_pdf(s, os.path.join(output_folder_path, f"{filename}.pdf"))
move(os.path.join(output_folder_path, f"{filename}.musicxml"), os.path.join(cache_folder_path, f"{filename}.musicxml"))
try:
s = stream.Stream()
add_metadata_to_stream(s, media_info.artist, media_info.title, int(media_info.bpm))
add_midi_segments_to_stream(s, midi_segments)
export_stream_to_pdf(s, os.path.join(output_folder_path, f"{filename}.pdf"))
move(os.path.join(output_folder_path, f"{filename}.musicxml"), os.path.join(cache_folder_path, f"{filename}.musicxml"))
except Exception as e:
song_error = (f"{media_info.artist} - {media_info.title}")
print(f"{ULTRASINGER_HEAD} {red_highlighted('Error: Could not create sheet for')} {blue_highlighted(song_error)}")
print(f"\t{red_highlighted(f'Error: ->{e}')}")
return
def round_to_nearest_quarter(number: float) -> float:
return round(number * 4) / 4