A lightweight yet powerful audio-to-MIDI converter with pitch bend detection
Python audiolightweightmachine-learningmidimusicpitch-detectionpolyphonicpythontranscriptiontypescript
change minimum_note_length to 127.7ms (11 frames)
Doherty Guirand179939e7e6f8
diff --git a/basic_pitch/inference.py b/basic_pitch/inference.pyindex 8591678..3b0032d 100644--- a/basic_pitch/inference.py+++ b/basic_pitch/inference.py@@ -117,6 +117,7 @@ def unwrap_output(output: Tensor, audio_original_length: int, n_overlapping_framoutput_shape = raw_output.shapen_output_frames_original = int(np.floor(audio_original_length * (ANNOTATIONS_FPS / AUDIO_SAMPLE_RATE)))unwrapped_output = raw_output.reshape(output_shape[0] * output_shape[1], output_shape[2])+ print("unwrapped_output:\n",unwrapped_output[:n_output_frames_original, :])return unwrapped_output[:n_output_frames_original, :] # trim to original audio length@@ -351,7 +352,7 @@ def predict_and_save(model_path: Union[pathlib.Path, str] = ICASSP_2022_MODEL_PATH,onset_threshold: float = 0.5,frame_threshold: float = 0.3,- minimum_note_length: float = 58,+ minimum_note_length: float = 127.70,minimum_frequency: Optional[float] = None,maximum_frequency: Optional[float] = None,multiple_pitch_bends: bool = False,diff --git a/basic_pitch/note_creation.py b/basic_pitch/note_creation.pyindex c8824e9..72a019b 100644--- a/basic_pitch/note_creation.py+++ b/basic_pitch/note_creation.py@@ -48,7 +48,7 @@ def model_output_to_notes(onset_thresh: float,frame_thresh: float,infer_onsets: bool = True,- min_note_len: int = 5,+ min_note_len: int = 11,min_freq: Optional[float] = None,max_freq: Optional[float] = None,include_pitch_bends: bool = True,@@ -396,6 +396,7 @@ def output_to_notes_polyphonic(# loop over onsetsnote_events = []for note_start_idx, freq_idx in zip(onset_time_idx, onset_freq_idx):+ print("freq_idx: ", freq_idx)# if we're too close to the end of the audio, continueif note_start_idx >= n_frames - 1:continue@@ -494,5 +495,6 @@ def output_to_notes_polyphonic(amplitude,))-+ print(note_events)+return note_events