From: Paul Brossier Date: Mon, 25 Apr 2016 16:56:13 +0000 (+0200) Subject: demos/demo_reading_speed.py: add reading speed tests X-Git-Tag: 0.4.4~300^2~206 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=07867cd07ec04d24b226b6af55ddaeac56be5665;p=aubio.git demos/demo_reading_speed.py: add reading speed tests --- diff --git a/python/demos/demo_reading_speed.py b/python/demos/demo_reading_speed.py new file mode 100644 index 00000000..e6fdb78d --- /dev/null +++ b/python/demos/demo_reading_speed.py @@ -0,0 +1,86 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +""" + +Compare the speed of several methods for reading and loading a sound file. + +This file depends on audioread and librosa: + https://github.com/beetbox/audioread + https://github.com/bmcfee/librosa + +""" + +import numpy as np +import aubio +import audioread +import librosa + +def read_file_audioread(filename): + # taken from librosa.util.utils + def convert_buffer_to_float(buf, n_bytes = 2, dtype = np.float32): + # Invert the scale of the data + scale = 1./float(1 << ((8 * n_bytes) - 1)) + # Construct the format string + fmt = '