librosa: numba's DTW segfaults on NaN similarity

Description

The example code plot_music_sync.py from https://librosa.github.io/librosa/auto_examples/plot_music_sync.html#sphx-glr-download-auto-examples-plot-music-sync-py runs fine with sir_duke_fast.mp3 and sir_duke_slow.mp3. But encounter segmentation fault when using other mp3 files.

Steps/Code to Reproduce

  1. Replace
x_1, fs = librosa.load('audio/sir_duke_fast.mp3')

to

x_1, fs = librosa.load('audio/BFJazz_-_Stargazer_from_Texas.mp3')

in plot_music_sync.py.

  1. Run plot_music_sync.py again and segmentation fault occurs.

  2. The exception seems to be thrown from this line:

D, wp = librosa.sequence.dtw(X=x_1_chroma, Y=x_2_chroma, metric='cosine')

Expected Results

Python should exit without Segmentation fault: 11

Actual Results

/Users/igneus/.pyenv/versions/3.7.4/lib/python3.7/site-packages/librosa/core/audio.py:146: UserWarning: PySoundFile failed. Trying audioread instead. warnings.warn(‘PySoundFile failed. Trying audioread instead.’) /Users/igneus/.pyenv/versions/3.7.4/lib/python3.7/site-packages/librosa/core/audio.py:146: UserWarning: PySoundFile failed. Trying audioread instead. warnings.warn(‘PySoundFile failed. Trying audioread instead.’) Segmentation fault: 11

Versions

Darwin-19.0.0-x86_64-i386-64bit Python 3.7.4 (default, Sep 26 2019, 17:15:53) [Clang 10.0.1 (clang-1001.0.46.4)] NumPy 1.17.3 SciPy 1.3.1 librosa 0.7.1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (15 by maintainers)

Most upvoted comments

The same happens with ‘braycurtis’

I converted the mp3 files to wav, and removed all plotting code. But the same segmentation error is still thrown from the dtw line.

Now the code is very simple:

from __future__ import print_function
import librosa

x_1, fs_1 = librosa.load('audio/sir_duke_fast.wav')
x_2, fs_2 = librosa.load('audio/BFJazz_-_Stargazer_from_Texas.wav')

n_fft = 4410
hop_size = 2205

x_1_chroma = librosa.feature.chroma_stft(y=x_1,
                                         sr=fs_1,
                                         tuning=0,
                                         norm=2,
                                         hop_length=hop_size,
                                         n_fft=n_fft)
x_2_chroma = librosa.feature.chroma_stft(y=x_2,
                                         sr=fs_2,
                                         tuning=0,
                                         norm=2,
                                         hop_length=hop_size,
                                         n_fft=n_fft)

# dtw line is where segmentation fault happens
D, wp = librosa.sequence.dtw(X=x_1_chroma, Y=x_2_chroma, metric='cosine')