From 85cfbf61846b984f448a5c9b85317dda6ae0d635 Mon Sep 17 00:00:00 2001 From: hyperc54 Date: Fri, 31 Oct 2025 19:25:51 +0100 Subject: [PATCH 1/2] Release constraint on mir_eval package --- basic_pitch/visualize.py | 10 +++++++++- pyproject.toml | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/basic_pitch/visualize.py b/basic_pitch/visualize.py index 2546d97..f9477f9 100644 --- a/basic_pitch/visualize.py +++ b/basic_pitch/visualize.py @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import numpy as np import tensorflow as tf import mir_eval @@ -188,12 +189,19 @@ def _array_to_sonification(array: tf.Tensor, max_outputs: int, clip: float = 0.3 audio_list = [] for i, gram in enumerate(gram_batch): + if gram.shape[1] != TIMES.shape[0]: + logging.warning( + f"Gram shape {gram.shape} does not match times shape {TIMES.shape}, times array will be truncated" + ) + times_truncated = TIMES[: min(gram.shape[1], TIMES.shape[0])] + else: + times_truncated = TIMES gram[gram < clip] = 0.0 y = mir_eval.sonify.time_frequency( gram[:MAX_FREQ_INDEX, :], FREQS[:MAX_FREQ_INDEX], - TIMES, + times_truncated, fs=SONIFY_FS, ) audio_list.append(y[:, np.newaxis]) diff --git a/pyproject.toml b/pyproject.toml index 48e89cd..2f4dedd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,9 +20,7 @@ classifiers = [ dependencies = [ "coremltools; platform_system == 'Darwin'", "librosa>=0.8.0", - # TODO: mir_eval 0.8.1+ introduces fixes to sonification that broke our tests - # Likely we'd like to adapt the tests to release the constraint - "mir_eval>=0.6,<=0.8.0", + "mir_eval>=0.8.1", "numpy>=1.18", "onnxruntime; platform_system == 'Windows' and python_version < '3.11'", "pretty_midi>=0.2.9", From d263e95e5b392c6e2610be332fff6e791d66eb38 Mon Sep 17 00:00:00 2001 From: hyperc54 Date: Fri, 31 Oct 2025 19:35:31 +0100 Subject: [PATCH 2/2] restore previous lower bound --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2f4dedd..22f744b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ dependencies = [ "coremltools; platform_system == 'Darwin'", "librosa>=0.8.0", - "mir_eval>=0.8.1", + "mir_eval>=0.6.0", "numpy>=1.18", "onnxruntime; platform_system == 'Windows' and python_version < '3.11'", "pretty_midi>=0.2.9",