diff --git a/README.md b/README.md index 13148f1..3933c5c 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This is relevant for machine learning models that today often process raw (time | [torchaudio](https://github.com/pytorch/audio) (soundfile) | 0.9.0 | `torchaudio` | PyTorch Tensor | all codecs supported by Soundfile | ✅ | | [soxbindings](https://github.com/pseeth/soxbindings) | 0.9.0 | `soxbindings` | Numpy Tensor | all codecs supported by Soundfile | ✅ | | [stempeg](https://github.com/faroit/stempeg) | 0.2.3 | `stempeg` | Numpy Tensor | all codecs supported by FFMPEG | ✅ | +| [pedalboard.io.AudioFile](https://github.com/spotify/pedalboard) | 0.5.1 | `pedalboard` | Numpy Array | WAV, AIFF, MP3, OGG, FLAC | ✅ | ### Not included diff --git a/benchmark_metadata.py b/benchmark_metadata.py index 6d56c47..f129924 100644 --- a/benchmark_metadata.py +++ b/benchmark_metadata.py @@ -62,6 +62,7 @@ def __len__(self): 'soundfile', 'sox', 'audioread', + 'pedalboard', ] for lib in libs: diff --git a/benchmark_np.py b/benchmark_np.py index 287ef50..b21d643 100644 --- a/benchmark_np.py +++ b/benchmark_np.py @@ -72,7 +72,8 @@ def test_np_loading(fp, lib): 'pydub', 'soundfile', 'librosa', - 'scipy_mmap' + 'scipy_mmap', + 'pedalboard', ] for lib in libs: diff --git a/benchmark_pytorch.py b/benchmark_pytorch.py index 1e8aff2..4085787 100644 --- a/benchmark_pytorch.py +++ b/benchmark_pytorch.py @@ -72,6 +72,7 @@ def __len__(self): 'librosa', 'scipy', 'scipy_mmap', + 'pedalboard', ] if args.ext != "mp4": diff --git a/benchmark_tf.py b/benchmark_tf.py index 6fd5b6e..1004c5f 100644 --- a/benchmark_tf.py +++ b/benchmark_tf.py @@ -59,6 +59,7 @@ def _py_loader_function(fp): 'scipy', 'scipy_mmap', 'tf_decode_wav', + 'pedalboard', ] for lib in libs: diff --git a/loaders.py b/loaders.py index 9d0d2d2..b12b80e 100644 --- a/loaders.py +++ b/loaders.py @@ -13,6 +13,7 @@ import soxbindings import sox import stempeg +import pedalboard """ @@ -121,6 +122,12 @@ def load_librosa(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 @@ -206,4 +213,14 @@ def info_stempeg(fp): info["samples"] = si.samples(0) info["channels"] = si.channels(0) info["duration"] = si.duration(0) - return info \ No newline at end of file + return info + + +def info_pedalboard(fp): + info = {} + with pedalboard.io.AudioFile(fp) as af: + info["sampling_rate"] = af.samplerate + info["samples"] = af.frames + info["channels"] = af.num_channels + info["duration"] = af.duration + return info diff --git a/requirements.txt b/requirements.txt index 9d607e7..364a8c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,3 +15,4 @@ seaborn pandas ipython cffi +pedalboard==0.5.1