Skip to content

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

Release constraint on `mir_eval` package (#183)

Pierre Tharyfe5e6e885ba1
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..22f744b 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.6.0",
"numpy>=1.18",
"onnxruntime; platform_system == 'Windows' and python_version < '3.11'",
"pretty_midi>=0.2.9",