Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC benchmark: remove aubio, use Python 3.10 #135

Merged
merged 6 commits into from
Nov 29, 2023
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
18 changes: 8 additions & 10 deletions docs/benchmark.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ Python packages

The following Python packages are benchmarked against each other:

* aubio_ 0.4.5
* 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
* audioread_ 3.0.1
* :mod:`audiofile` 1.3.0
* librosa_ 0.10.1
* pedalboard_ 0.8.6
* scipy_ 1.11.4
* soundfile_ 0.21.1
* sox_ 1.4.1

scipy_ and librosa_ are only tested for reading files,
Expand Down Expand Up @@ -75,7 +74,7 @@ The benchmark was executed on the following machine:
* RAM: 15.37 GB
* Hard drive: Samsung SSD 860
* Linux: Ubuntu 18.04.6
* Python: 3.8.13
* Python: 3.10.11

To rerun the benchmark yourself,
clone the repository
Expand All @@ -88,7 +87,7 @@ and execute:
$ bash generate_audio.sh
$ bash run.sh

This requires that Python 3.8 is installed
This requires that Python 3.10 is installed
and will ask for a sudo password
to install missing apt packages.

Expand Down Expand Up @@ -153,7 +152,6 @@ and is shown as audiofile (sloppy)
in the figure.


.. _aubio: https://github.com/aubio/aubio/
.. _audioread: https://github.com/beetbox/audioread/
.. _ffmpeg: https://ffmpeg.org/
.. _gstreamer: https://gstreamer.freedesktop.org/
Expand Down
1 change: 0 additions & 1 deletion docs/benchmark/benchmark_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def __len__(self):
libs = [
'ar_ffmpeg',
'ar_mad',
'aubio',
'audiofile',
'audiofile_sloppy',
'pedalboard',
Expand Down
1 change: 0 additions & 1 deletion docs/benchmark/benchmark_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def __len__(self):
libs = [
'ar_ffmpeg',
'ar_mad',
'aubio',
'audiofile',
'librosa',
'pedalboard',
Expand Down
11 changes: 3 additions & 8 deletions docs/benchmark/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Libraries for audioread and aubio
sudo apt-get install -y libmad0-dev sox ffmpeg libaubio-dev
# Libraries for audioread
sudo apt-get install -y libmad0-dev sox ffmpeg
sudo apt-get install -y libavresample-dev libswresample-dev libavutil-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libsamplerate0-dev

Expand All @@ -12,16 +12,11 @@ then
fi
ENV_DIR="${HOME}/.envs/audiofile-benchmark"
rm -rf ${ENV_DIR}
virtualenv --python=python3.8 ${ENV_DIR}
virtualenv --python=python3.10 ${ENV_DIR}
source ${ENV_DIR}/bin/activate
pip install --upgrade pip

# Enforce rebuilding of wheels
pip cache purge

# Fix numpy header include for aubio
pip install "numpy==1.21.6"
mkdir -p ${ENV_DIR}/include/
ln -sf ${ENV_DIR}lib/python3.8/site-packages/numpy/core/include/numpy ${ENV_DIR}/include/

pip install -r requirements.txt.lock
28 changes: 0 additions & 28 deletions docs/benchmark/loaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import aubio
import audiofile as af
import audioread.rawread
import audioread.gstdec
Expand All @@ -17,20 +16,6 @@
"""


def load_aubio(fp):
f = aubio.source(fp, hop_size=1024)
sig = np.zeros(f.duration, dtype=aubio.float_type)
total_frames = 0
while True:
samples, read = f()
if total_frames + read <= f.duration:
sig[total_frames:total_frames + read] = samples[:read]
total_frames += read
if read < f.hop_size:
break
return sig


def load_soundfile(fp):
sig, rate = sf.read(fp)
return sig
Expand Down Expand Up @@ -156,19 +141,6 @@ def info_ar_ffmpeg(fp):
return info


def info_aubio(fp):
info = {}
with aubio.source(fp) as f:
info['duration'] = f.duration / f.samplerate
with aubio.source(fp) as f:
info['samples'] = f.duration
with aubio.source(fp) as f:
info['channels'] = f.channels
with aubio.source(fp) as f:
info['sampling_rate'] = f.samplerate
return info


def info_sox(fp):
info = {}
info['duration'] = sox.file_info.duration(fp)
Expand Down
11 changes: 2 additions & 9 deletions docs/benchmark/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
NBFILES = 10 # must be identical to generate_audio.sh

MAPPINGS = { # library name mappings
'aubio': 'aubio',
'audiofile': 'audiofile',
'audiofile_sloppy': 'audiofile (sloppy)',
'ar_ffmpeg': 'audioread (ffmpeg)',
Expand Down Expand Up @@ -42,7 +41,6 @@
lib_order = [
MAPPINGS['audiofile'],
MAPPINGS['soundfile'],
MAPPINGS['aubio'],
MAPPINGS['librosa'],
MAPPINGS['ar_ffmpeg'],
MAPPINGS['pedalboard'],
Expand All @@ -54,15 +52,13 @@
lib_order = [
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['aubio'],
MAPPINGS['librosa'],
MAPPINGS['ar_ffmpeg'],
MAPPINGS['ar_mad'],
Expand All @@ -74,7 +70,6 @@
lib_order = [
MAPPINGS['audiofile'],
MAPPINGS['audiofile_sloppy'],
MAPPINGS['aubio'],
MAPPINGS['ar_ffmpeg'],
MAPPINGS['ar_mad'],
MAPPINGS['pedalboard'],
Expand All @@ -90,13 +85,12 @@
MAPPINGS['audiofile']: '#4a74b5',
MAPPINGS['audiofile_sloppy']: '#6b93d7',
MAPPINGS['soundfile']: '#db8548',
MAPPINGS['aubio']: '#5dab64',
MAPPINGS['librosa']: '#c34c4d',
MAPPINGS['scipy']: '#8174b8',
MAPPINGS['ar_mad']: '#94785e',
MAPPINGS['ar_ffmpeg']: '#94785e',
MAPPINGS['sox']: '#db8cc5',
MAPPINGS['pedalboard']: '#cdbb75',
MAPPINGS['pedalboard']: '#5dab64',
}

g = sns.catplot(
Expand All @@ -110,10 +104,9 @@
data=y,
height=height,
aspect=aspect,
legend=False
legend=True,
)
g.despine(left=True)
plt.legend(loc='upper right')
plt.xlabel('time / s per file')
plt.ylabel('file format')
if package == 'info':
Expand Down
5 changes: 2 additions & 3 deletions docs/benchmark/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
aubio ==0.4.5
audiofile
audioread
librosa
pandas
pedalboard ==0.5.3
pygobject
pedalboard
pygobject==3.42.1
pymad
scipy
seaborn
Expand Down
Loading