Mercurial > hg > dhoxss15
changeset 6:c4eb7acfb989
Another audio file, further notebook updates
| author | Chris Cannam |
|---|---|
| date | Thu, 16 Jul 2015 09:56:49 +0100 |
| parents | c5482b2a4bdd |
| children | 295ba236f53c |
| files | Vamp.ipynb Vamp.v3.ipynb data/A Friendly Warning.ogg |
| diffstat | 3 files changed, 120 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/Vamp.ipynb Thu Jul 16 09:24:49 2015 +0100 +++ b/Vamp.ipynb Thu Jul 16 09:56:49 2015 +0100 @@ -1,50 +1,49 @@ { "cells": [ { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Using Vamp plugins from Python\n", + "This notebook illustrates processing an audio file using a Vamp plugin, showing the results in a simple plot, and saving to a .csv file. This could be useful when integrating with analysis software written in Python, or for a batch process. (Note that it is also possible to run Vamp plugins in batch using the [Sonic Annotator](http://vamp-plugins.org/sonic-annotator) command-line program.)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Setup\n", + "\n", + "First import some necessary modules.\n", + "\n", + "The `vamp` module loads and runs Vamp plugins.\n", + "`librosa` is an audio analysis module from LabROSA at Columbia University. We are using it here only to load audio files, though it can also carry out some basic analysis functions.\n", + "`matplotlib` is the plotting library." + ] + }, + { "cell_type": "code", - "execution_count": 1, + "execution_count": 26, "metadata": { "collapsed": true }, "outputs": [], "source": [ - "import vamp" + "import vamp\n", + "import librosa\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This bit of magic ensures that plots show up in the notebook rather than in a separate window:" ] }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/usr/lib/python2.7/site-packages/librosa/core/audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal\n", - " warnings.warn('Could not import scikits.samplerate. '\n" - ] - } - ], - "source": [ - "import librosa" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "code", - "execution_count": 4, + "execution_count": 27, "metadata": { "collapsed": true }, @@ -54,10 +53,22 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Getting started with the Vamp module\n", + "\n", + "List the plugins that are installed. The strings that are returned here are referred to in the module documentation as _plugin keys_ -- each one consists of the name of the library file that contains the plugin, then a colon, then the identifier for the plugin itself. So a set of plugins with the same text before the colon (such as `qm-vamp-plugins:`) were all distributed in the same plugin library file.\n", + "\n", + "You can find plugin descriptions and downloads at http://vamp-plugins.org/download.html." + ] + }, + { "cell_type": "code", - "execution_count": 5, + "execution_count": 28, "metadata": { - "collapsed": false + "collapsed": false, + "scrolled": true }, "outputs": [ { @@ -161,7 +172,7 @@ " 'vamp-test-plugin:vamp-test-plugin-freq']" ] }, - "execution_count": 5, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -171,8 +182,15 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We'll be using the `librosa` module's `load` function to load the audio file. IPython will show documentation about a function if you just give its name with a \"?\" at the end." + ] + }, + { "cell_type": "code", - "execution_count": 6, + "execution_count": 29, "metadata": { "collapsed": true }, @@ -182,6 +200,13 @@ ] }, { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And the main high-level Vamp module function to apply a plugin is called `collect`, because it runs a plugin and collects the results into a suitable structure rather than returning them individually." + ] + }, + { "cell_type": "code", "execution_count": 7, "metadata": {
--- a/Vamp.v3.ipynb Thu Jul 16 09:24:49 2015 +0100 +++ b/Vamp.v3.ipynb Thu Jul 16 09:56:49 2015 +0100 @@ -25,46 +25,45 @@ { "cells": [ { - "cell_type": "code", - "collapsed": true, - "input": [ - "import vamp" - ], - "language": "python", + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "prompt_number": 1 + "source": [ + "# Using Vamp plugins from Python\n", + "This notebook illustrates processing an audio file using a Vamp plugin, showing the results in a simple plot, and saving to a .csv file. This could be useful when integrating with analysis software written in Python, or for a batch process. (Note that it is also possible to run Vamp plugins in batch using the [Sonic Annotator](http://vamp-plugins.org/sonic-annotator) command-line program.)" + ] }, { - "cell_type": "code", - "collapsed": false, - "input": [ - "import librosa" - ], - "language": "python", + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stderr", - "text": [ - "/usr/lib/python2.7/site-packages/librosa/core/audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal\n", - " warnings.warn('Could not import scikits.samplerate. '\n" - ] - } - ], - "prompt_number": 2 + "source": [ + "### Setup\n", + "\n", + "First import some necessary modules.\n", + "\n", + "The `vamp` module loads and runs Vamp plugins.\n", + "`librosa` is an audio analysis module from LabROSA at Columbia University. We are using it here only to load audio files, though it can also carry out some basic analysis functions.\n", + "`matplotlib` is the plotting library." + ] }, { "cell_type": "code", "collapsed": true, "input": [ + "import vamp\n", + "import librosa\n", "import matplotlib.pyplot as plt" ], "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 3 + "prompt_number": 26 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This bit of magic ensures that plots show up in the notebook rather than in a separate window:" + ] }, { "cell_type": "code", @@ -75,7 +74,18 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 4 + "prompt_number": 27 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Getting started with the Vamp module\n", + "\n", + "List the plugins that are installed. The strings that are returned here are referred to in the module documentation as _plugin keys_ -- each one consists of the name of the library file that contains the plugin, then a colon, then the identifier for the plugin itself. So a set of plugins with the same text before the colon (such as `qm-vamp-plugins:`) were all distributed in the same plugin library file.\n", + "\n", + "You can find plugin descriptions and downloads at http://vamp-plugins.org/download.html." + ] }, { "cell_type": "code", @@ -84,12 +94,14 @@ "vamp.list_plugins()" ], "language": "python", - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "metadata": {}, "output_type": "pyout", - "prompt_number": 5, + "prompt_number": 28, "text": [ "['bbc-vamp-plugins:bbc-energy',\n", " 'bbc-vamp-plugins:bbc-intensity',\n", @@ -190,7 +202,14 @@ ] } ], - "prompt_number": 5 + "prompt_number": 28 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We'll be using the `librosa` module's `load` function to load the audio file. IPython will show documentation about a function if you just give its name with a \"?\" at the end." + ] }, { "cell_type": "code", @@ -201,7 +220,14 @@ "language": "python", "metadata": {}, "outputs": [], - "prompt_number": 6 + "prompt_number": 29 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And the main high-level Vamp module function to apply a plugin is called `collect`, because it runs a plugin and collects the results into a suitable structure rather than returning them individually." + ] }, { "cell_type": "code",
