Skip to content

A lightweight yet powerful audio-to-MIDI converter with pitch bend detection

better exception/error handling here

Saltine64c15684c160
diff --git a/basic_pitch/commandline_printing.py b/basic_pitch/commandline_printing.py
index 6cf1248..4e8c73a 100644
--- a/basic_pitch/commandline_printing.py
+++ b/basic_pitch/commandline_printing.py
@@ -39,8 +39,7 @@ def generating_file_message(output_type: str) -> None:
output_type: string indicating which kind of file is being generated
"""
- print(f"\n\n Creating {output_type.replace('_', ' ').lower()}...")
-
+ print(f"\n\n{DEFAULT_PRINT_INDENT}Creating {output_type.replace('_', ' ').lower()}...")
def file_saved_confirmation(output_type: str, save_path: Union[pathlib.Path, str]) -> None:
"""Print a confirmation that the file was saved succesfully
@@ -50,8 +49,8 @@ def file_saved_confirmation(output_type: str, save_path: Union[pathlib.Path, str
save_path: The path to output file.
"""
- print(f" {OUTPUT_EMOJIS[output_type]} Saved to {save_path}")
-
+ emoji = OUTPUT_EMOJIS.get(output_type, "")
+ print(f"{DEFAULT_PRINT_INDENT}{emoji} Saved to {save_path}")
def failed_to_save(output_type: str, save_path: Union[pathlib.Path, str]) -> None:
"""Print a failure to save message
@@ -63,7 +62,6 @@ def failed_to_save(output_type: str, save_path: Union[pathlib.Path, str]) -> Non
"""
print(f"\n🚨 Failed to save {output_type.replace('_', ' ').lower()} to {save_path} \n")
-
@contextmanager
def no_tf_warnings() -> Iterator[None]:
"""
@@ -71,5 +69,7 @@ def no_tf_warnings() -> Iterator[None]:
"""
tf_logging_level = os.environ.get(TF_LOG_LEVEL_KEY, TF_LOG_LEVEL_NO_WARNINGS_VALUE)
os.environ[TF_LOG_LEVEL_KEY] = TF_LOG_LEVEL_NO_WARNINGS_VALUE
- yield
- os.environ[TF_LOG_LEVEL_KEY] = tf_logging_level
+ try:
+ yield
+ finally:
+ os.environ[TF_LOG_LEVEL_KEY] = tf_logging_level