Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/benchmark.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The following Python packages are benchmarked against each other:
* audioread_ 2.1.9
* :mod:`audiofile` 1.1.0
* librosa_ 0.9.1
* pedalboard_ 0.5.3
* scipy_ 1.8.0
* soundfile_ 0.10.3.post1
* sox_ 1.4.1
Expand Down Expand Up @@ -126,7 +127,7 @@ Reading files

soundfile_ does not support
reading MP3 and MP4 files,
audioread_ (mad) only MP3 files.
audioread_ (mad) and pedalboard_ only MP3 files.

.. image:: ./benchmark/results/benchmark_mp3-mp4_read.png

Expand All @@ -135,7 +136,7 @@ Accessing metadata

soundfile_ does not support
accessing MP3 and MP4 metadata.
sox_ and audioread_ (mad) only for MP3 files.
sox_, audioread_ (mad) and pedalboard_ only for MP3 files.

.. image:: ./benchmark/results/benchmark_mp3-mp4_info.png

Expand All @@ -158,6 +159,7 @@ in the figure.
.. _gstreamer: https://gstreamer.freedesktop.org/
.. _librosa: https://github.com/librosa/librosa/
.. _mad: https://sourceforge.net/projects/mad/
.. _pedalboard: https://github.com/spotify/pedalboard
.. _scipy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.wavfile.read.html
.. _soundfile: https://github.com/bastibe/SoundFile/
.. _sox: https://github.com/rabitt/pysox/
Expand Down
8 changes: 7 additions & 1 deletion docs/benchmark/benchmark_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __len__(self):
'aubio',
'audiofile',
'audiofile_sloppy',
'pedalboard',
'soundfile',
'sox',
]
Expand All @@ -68,13 +69,18 @@ def __len__(self):
print(f"Benchmark metadata {args.ext} with {lib}")
for root, dirs, fnames in sorted(os.walk('AUDIO')):
for audio_dir in dirs:

# MP4 and MP3 is not supported by all libraries
if lib in ['soundfile', 'sox'] and args.ext == 'mp4':
if (
lib in ['soundfile', 'sox', 'pedalboard']
and args.ext == 'mp4'
):
continue
if lib in ['soundfile'] and args.ext == 'mp3':
continue
if lib == 'ar_mad' and args.ext != 'mp3':
continue

duration = int(audio_dir)
dataset = AudioFolder(
os.path.join(root, audio_dir),
Expand Down
3 changes: 3 additions & 0 deletions docs/benchmark/benchmark_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __len__(self):
'aubio',
'audiofile',
'librosa',
'pedalboard',
'scipy',
'soundfile',
]
Expand All @@ -82,6 +83,8 @@ def __len__(self):
continue
if lib == 'soundfile' and args.ext in ['mp3', 'mp4']:
continue
if lib == 'pedalboard' and args.ext == 'mp4':
continue

duration = int(audio_dir)
dataset = AudioFolder(
Expand Down
26 changes: 23 additions & 3 deletions docs/benchmark/loaders.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from scipy.io import wavfile
import aubio
import audiofile as af
import audioread.rawread
import audioread.gstdec
import audioread.maddec
import audioread.ffdec
import pedalboard
import soundfile as sf
import audiofile as af
import aubio
import numpy as np
import librosa
from scipy.io import wavfile
import sox

"""
Expand Down Expand Up @@ -90,6 +91,12 @@ def load_audiofile(fp):
return sig


def load_pedalboard(fp):
with pedalboard.io.AudioFile(fp) as f:
# Pedalboard output is (num_channels, num_samples)
return f.read(f.frames)[0]


def _convert_buffer_to_float(buf, n_bytes=2, dtype=np.float32):
# taken from librosa.util.utils
# Invert the scale of the data
Expand Down Expand Up @@ -187,3 +194,16 @@ def info_audiofile_sloppy(fp):
info['channels'] = af.channels
info['sampling_rate'] = af.sampling_rate
return info


def info_pedalboard(fp):
info = {}
with pedalboard.io.AudioFile(fp) as af:
info["duration"] = af.duration
with pedalboard.io.AudioFile(fp) as af:
info["samples"] = af.frames
with pedalboard.io.AudioFile(fp) as af:
info["channels"] = af.num_channels
with pedalboard.io.AudioFile(fp) as af:
info["sampling_rate"] = af.samplerate
return info
8 changes: 7 additions & 1 deletion docs/benchmark/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
'ar_ffmpeg': 'audioread (ffmpeg)',
'ar_mad': 'audioread (mad)',
'librosa': 'librosa',
'pedalboard': 'pedalboard',
'scipy': 'scipy',
'soundfile': 'soundfile',
'sox': 'sox',
Expand Down Expand Up @@ -44,6 +45,7 @@
MAPPINGS['aubio'],
MAPPINGS['librosa'],
MAPPINGS['ar_ffmpeg'],
MAPPINGS['pedalboard'],
MAPPINGS['scipy'],
]
height = 5.6
Expand All @@ -53,16 +55,18 @@
MAPPINGS['audiofile'],
MAPPINGS['soundfile'],
MAPPINGS['aubio'],
MAPPINGS['pedalboard'],
]
height = 3.36
aspect = 2.0
elif 'mp3' in exts and package == 'read':
lib_order = [
MAPPINGS['audiofile'],
MAPPINGS['librosa'],
MAPPINGS['aubio'],
MAPPINGS['librosa'],
MAPPINGS['ar_ffmpeg'],
MAPPINGS['ar_mad'],
MAPPINGS['pedalboard'],
]
height = 3.36
aspect = 2.0
Expand All @@ -73,6 +77,7 @@
MAPPINGS['aubio'],
MAPPINGS['ar_ffmpeg'],
MAPPINGS['ar_mad'],
MAPPINGS['pedalboard'],
MAPPINGS['sox'],
]
height = 3.7
Expand All @@ -91,6 +96,7 @@
MAPPINGS['ar_mad']: '#94785e',
MAPPINGS['ar_ffmpeg']: '#94785e',
MAPPINGS['sox']: '#db8cc5',
MAPPINGS['pedalboard']: '#cdbb75',
}

g = sns.catplot(
Expand Down
1 change: 1 addition & 0 deletions docs/benchmark/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ audiofile
audioread
librosa
pandas
pedalboard ==0.5.3
pygobject
pymad
scipy
Expand Down
3 changes: 3 additions & 0 deletions docs/benchmark/requirements.txt.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ numpy==1.21.6
# matplotlib
# numba
# pandas
# pedalboard
# resampy
# scikit-learn
# scipy
Expand All @@ -70,6 +71,8 @@ pandas==1.4.2
# via
# -r requirements.txt
# seaborn
pedalboard==0.5.3
# via -r requirements.txt
pillow==9.1.0
# via matplotlib
pooch==1.6.0
Expand Down
Binary file modified docs/benchmark/results/benchmark_info_flac.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_info_mp3.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_info_mp4.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_info_ogg.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_info_wav.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_mp3-mp4_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/benchmark/results/benchmark_mp3-mp4_read.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/benchmark/results/benchmark_read_flac.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_read_mp3.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_read_mp4.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_read_ogg.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_read_wav.pickle
Binary file not shown.
Binary file modified docs/benchmark/results/benchmark_wav-flac-ogg_info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/benchmark/results/benchmark_wav-flac-ogg_read.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.