|
20 | 20 | import json |
21 | 21 | import os |
22 | 22 | import pathlib |
23 | | -import traceback |
24 | 23 | from typing import Dict, List, Optional, Sequence, Tuple, Union |
25 | 24 |
|
26 | 25 | from tensorflow import Tensor, signal, keras, saved_model |
@@ -405,33 +404,38 @@ def predict_and_save( |
405 | 404 | try: |
406 | 405 | np.savez(model_output_path, basic_pitch_model_output=model_output) |
407 | 406 | file_saved_confirmation(OutputExtensions.MODEL_OUTPUT_NPZ.name, model_output_path) |
408 | | - except Exception: |
| 407 | + except Exception as e: |
409 | 408 | failed_to_save(OutputExtensions.MODEL_OUTPUT_NPZ.name, model_output_path) |
| 409 | + raise e |
410 | 410 |
|
411 | 411 | if save_midi: |
412 | | - midi_path = build_output_path(audio_path, output_directory, OutputExtensions.MIDI) |
| 412 | + try: |
| 413 | + midi_path = build_output_path(audio_path, output_directory, OutputExtensions.MIDI) |
| 414 | + except IOError as e: |
| 415 | + raise e |
413 | 416 | try: |
414 | 417 | midi_data.write(str(midi_path)) |
415 | 418 | file_saved_confirmation(OutputExtensions.MIDI.name, midi_path) |
416 | | - except Exception: |
| 419 | + except Exception as e: |
417 | 420 | failed_to_save(OutputExtensions.MIDI.name, midi_path) |
| 421 | + raise e |
418 | 422 |
|
419 | 423 | if sonify_midi: |
420 | 424 | midi_sonify_path = build_output_path(audio_path, output_directory, OutputExtensions.MIDI_SONIFICATION) |
421 | 425 | try: |
422 | 426 | infer.sonify_midi(midi_data, midi_sonify_path, sr=sonification_samplerate) |
423 | 427 | file_saved_confirmation(OutputExtensions.MIDI_SONIFICATION.name, midi_sonify_path) |
424 | | - except Exception: |
| 428 | + except Exception as e: |
425 | 429 | failed_to_save(OutputExtensions.MIDI_SONIFICATION.name, midi_sonify_path) |
| 430 | + raise e |
426 | 431 |
|
427 | 432 | if save_notes: |
428 | 433 | note_events_path = build_output_path(audio_path, output_directory, OutputExtensions.NOTE_EVENTS) |
429 | 434 | try: |
430 | 435 | save_note_events(note_events, note_events_path) |
431 | 436 | file_saved_confirmation(OutputExtensions.NOTE_EVENTS.name, note_events_path) |
432 | | - except Exception: |
| 437 | + except Exception as e: |
433 | 438 | failed_to_save(OutputExtensions.NOTE_EVENTS.name, note_events_path) |
434 | | - except Exception: |
435 | | - print("🚨 Something went wrong 😔 - see the traceback below for details.") |
436 | | - print("") |
437 | | - print(traceback.format_exc()) |
| 439 | + raise e |
| 440 | + except Exception as e: |
| 441 | + raise e |
0 commit comments