From 07867cd07ec04d24b226b6af55ddaeac56be5665 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Mon, 25 Apr 2016 18:56:13 +0200 Subject: [PATCH] demos/demo_reading_speed.py: add reading speed tests --- python/demos/demo_reading_speed.py | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 python/demos/demo_reading_speed.py 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 = '