Revision 6:c4eb7acfb989
| Vamp.ipynb | ||
|---|---|---|
| 1 | 1 |
{
|
| 2 | 2 |
"cells": [ |
| 3 | 3 |
{
|
| 4 |
"cell_type": "markdown", |
|
| 5 |
"metadata": {},
|
|
| 6 |
"source": [ |
|
| 7 |
"# Using Vamp plugins from Python\n", |
|
| 8 |
"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.)" |
|
| 9 |
] |
|
| 10 |
}, |
|
| 11 |
{
|
|
| 12 |
"cell_type": "markdown", |
|
| 13 |
"metadata": {},
|
|
| 14 |
"source": [ |
|
| 15 |
"### Setup\n", |
|
| 16 |
"\n", |
|
| 17 |
"First import some necessary modules.\n", |
|
| 18 |
"\n", |
|
| 19 |
"The `vamp` module loads and runs Vamp plugins.\n", |
|
| 20 |
"`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", |
|
| 21 |
"`matplotlib` is the plotting library." |
|
| 22 |
] |
|
| 23 |
}, |
|
| 24 |
{
|
|
| 4 | 25 |
"cell_type": "code", |
| 5 |
"execution_count": 1,
|
|
| 26 |
"execution_count": 26,
|
|
| 6 | 27 |
"metadata": {
|
| 7 | 28 |
"collapsed": true |
| 8 | 29 |
}, |
| 9 | 30 |
"outputs": [], |
| 10 | 31 |
"source": [ |
| 11 |
"import vamp" |
|
| 32 |
"import vamp\n", |
|
| 33 |
"import librosa\n", |
|
| 34 |
"import matplotlib.pyplot as plt" |
|
| 35 |
] |
|
| 36 |
}, |
|
| 37 |
{
|
|
| 38 |
"cell_type": "markdown", |
|
| 39 |
"metadata": {},
|
|
| 40 |
"source": [ |
|
| 41 |
"This bit of magic ensures that plots show up in the notebook rather than in a separate window:" |
|
| 12 | 42 |
] |
| 13 | 43 |
}, |
| 14 | 44 |
{
|
| 15 | 45 |
"cell_type": "code", |
| 16 |
"execution_count": 2, |
|
| 17 |
"metadata": {
|
|
| 18 |
"collapsed": false |
|
| 19 |
}, |
|
| 20 |
"outputs": [ |
|
| 21 |
{
|
|
| 22 |
"name": "stderr", |
|
| 23 |
"output_type": "stream", |
|
| 24 |
"text": [ |
|
| 25 |
"/usr/lib/python2.7/site-packages/librosa/core/audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal\n", |
|
| 26 |
" warnings.warn('Could not import scikits.samplerate. '\n"
|
|
| 27 |
] |
|
| 28 |
} |
|
| 29 |
], |
|
| 30 |
"source": [ |
|
| 31 |
"import librosa" |
|
| 32 |
] |
|
| 33 |
}, |
|
| 34 |
{
|
|
| 35 |
"cell_type": "code", |
|
| 36 |
"execution_count": 3, |
|
| 37 |
"metadata": {
|
|
| 38 |
"collapsed": true |
|
| 39 |
}, |
|
| 40 |
"outputs": [], |
|
| 41 |
"source": [ |
|
| 42 |
"import matplotlib.pyplot as plt" |
|
| 43 |
] |
|
| 44 |
}, |
|
| 45 |
{
|
|
| 46 |
"cell_type": "code", |
|
| 47 |
"execution_count": 4, |
|
| 46 |
"execution_count": 27, |
|
| 48 | 47 |
"metadata": {
|
| 49 | 48 |
"collapsed": true |
| 50 | 49 |
}, |
| ... | ... | |
| 54 | 53 |
] |
| 55 | 54 |
}, |
| 56 | 55 |
{
|
| 56 |
"cell_type": "markdown", |
|
| 57 |
"metadata": {},
|
|
| 58 |
"source": [ |
|
| 59 |
"### Getting started with the Vamp module\n", |
|
| 60 |
"\n", |
|
| 61 |
"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", |
|
| 62 |
"\n", |
|
| 63 |
"You can find plugin descriptions and downloads at http://vamp-plugins.org/download.html." |
|
| 64 |
] |
|
| 65 |
}, |
|
| 66 |
{
|
|
| 57 | 67 |
"cell_type": "code", |
| 58 |
"execution_count": 5,
|
|
| 68 |
"execution_count": 28,
|
|
| 59 | 69 |
"metadata": {
|
| 60 |
"collapsed": false |
|
| 70 |
"collapsed": false, |
|
| 71 |
"scrolled": true |
|
| 61 | 72 |
}, |
| 62 | 73 |
"outputs": [ |
| 63 | 74 |
{
|
| ... | ... | |
| 161 | 172 |
" 'vamp-test-plugin:vamp-test-plugin-freq']" |
| 162 | 173 |
] |
| 163 | 174 |
}, |
| 164 |
"execution_count": 5,
|
|
| 175 |
"execution_count": 28,
|
|
| 165 | 176 |
"metadata": {},
|
| 166 | 177 |
"output_type": "execute_result" |
| 167 | 178 |
} |
| ... | ... | |
| 171 | 182 |
] |
| 172 | 183 |
}, |
| 173 | 184 |
{
|
| 185 |
"cell_type": "markdown", |
|
| 186 |
"metadata": {},
|
|
| 187 |
"source": [ |
|
| 188 |
"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." |
|
| 189 |
] |
|
| 190 |
}, |
|
| 191 |
{
|
|
| 174 | 192 |
"cell_type": "code", |
| 175 |
"execution_count": 6,
|
|
| 193 |
"execution_count": 29,
|
|
| 176 | 194 |
"metadata": {
|
| 177 | 195 |
"collapsed": true |
| 178 | 196 |
}, |
| ... | ... | |
| 182 | 200 |
] |
| 183 | 201 |
}, |
| 184 | 202 |
{
|
| 203 |
"cell_type": "markdown", |
|
| 204 |
"metadata": {},
|
|
| 205 |
"source": [ |
|
| 206 |
"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." |
|
| 207 |
] |
|
| 208 |
}, |
|
| 209 |
{
|
|
| 185 | 210 |
"cell_type": "code", |
| 186 | 211 |
"execution_count": 7, |
| 187 | 212 |
"metadata": {
|
| Vamp.v3.ipynb | ||
|---|---|---|
| 25 | 25 |
{
|
| 26 | 26 |
"cells": [ |
| 27 | 27 |
{
|
| 28 |
"cell_type": "code", |
|
| 29 |
"collapsed": true, |
|
| 30 |
"input": [ |
|
| 31 |
"import vamp" |
|
| 32 |
], |
|
| 33 |
"language": "python", |
|
| 28 |
"cell_type": "markdown", |
|
| 34 | 29 |
"metadata": {},
|
| 35 |
"outputs": [], |
|
| 36 |
"prompt_number": 1 |
|
| 30 |
"source": [ |
|
| 31 |
"# Using Vamp plugins from Python\n", |
|
| 32 |
"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.)" |
|
| 33 |
] |
|
| 37 | 34 |
}, |
| 38 | 35 |
{
|
| 39 |
"cell_type": "code", |
|
| 40 |
"collapsed": false, |
|
| 41 |
"input": [ |
|
| 42 |
"import librosa" |
|
| 43 |
], |
|
| 44 |
"language": "python", |
|
| 36 |
"cell_type": "markdown", |
|
| 45 | 37 |
"metadata": {},
|
| 46 |
"outputs": [ |
|
| 47 |
{
|
|
| 48 |
"output_type": "stream", |
|
| 49 |
"stream": "stderr", |
|
| 50 |
"text": [ |
|
| 51 |
"/usr/lib/python2.7/site-packages/librosa/core/audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal\n", |
|
| 52 |
" warnings.warn('Could not import scikits.samplerate. '\n"
|
|
| 53 |
] |
|
| 54 |
} |
|
| 55 |
], |
|
| 56 |
"prompt_number": 2 |
|
| 38 |
"source": [ |
|
| 39 |
"### Setup\n", |
|
| 40 |
"\n", |
|
| 41 |
"First import some necessary modules.\n", |
|
| 42 |
"\n", |
|
| 43 |
"The `vamp` module loads and runs Vamp plugins.\n", |
|
| 44 |
"`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", |
|
| 45 |
"`matplotlib` is the plotting library." |
|
| 46 |
] |
|
| 57 | 47 |
}, |
| 58 | 48 |
{
|
| 59 | 49 |
"cell_type": "code", |
| 60 | 50 |
"collapsed": true, |
| 61 | 51 |
"input": [ |
| 52 |
"import vamp\n", |
|
| 53 |
"import librosa\n", |
|
| 62 | 54 |
"import matplotlib.pyplot as plt" |
| 63 | 55 |
], |
| 64 | 56 |
"language": "python", |
| 65 | 57 |
"metadata": {},
|
| 66 | 58 |
"outputs": [], |
| 67 |
"prompt_number": 3 |
|
| 59 |
"prompt_number": 26 |
|
| 60 |
}, |
|
| 61 |
{
|
|
| 62 |
"cell_type": "markdown", |
|
| 63 |
"metadata": {},
|
|
| 64 |
"source": [ |
|
| 65 |
"This bit of magic ensures that plots show up in the notebook rather than in a separate window:" |
|
| 66 |
] |
|
| 68 | 67 |
}, |
| 69 | 68 |
{
|
| 70 | 69 |
"cell_type": "code", |
| ... | ... | |
| 75 | 74 |
"language": "python", |
| 76 | 75 |
"metadata": {},
|
| 77 | 76 |
"outputs": [], |
| 78 |
"prompt_number": 4 |
|
| 77 |
"prompt_number": 27 |
|
| 78 |
}, |
|
| 79 |
{
|
|
| 80 |
"cell_type": "markdown", |
|
| 81 |
"metadata": {},
|
|
| 82 |
"source": [ |
|
| 83 |
"### Getting started with the Vamp module\n", |
|
| 84 |
"\n", |
|
| 85 |
"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", |
|
| 86 |
"\n", |
|
| 87 |
"You can find plugin descriptions and downloads at http://vamp-plugins.org/download.html." |
|
| 88 |
] |
|
| 79 | 89 |
}, |
| 80 | 90 |
{
|
| 81 | 91 |
"cell_type": "code", |
| ... | ... | |
| 84 | 94 |
"vamp.list_plugins()" |
| 85 | 95 |
], |
| 86 | 96 |
"language": "python", |
| 87 |
"metadata": {},
|
|
| 97 |
"metadata": {
|
|
| 98 |
"scrolled": true |
|
| 99 |
}, |
|
| 88 | 100 |
"outputs": [ |
| 89 | 101 |
{
|
| 90 | 102 |
"metadata": {},
|
| 91 | 103 |
"output_type": "pyout", |
| 92 |
"prompt_number": 5,
|
|
| 104 |
"prompt_number": 28,
|
|
| 93 | 105 |
"text": [ |
| 94 | 106 |
"['bbc-vamp-plugins:bbc-energy',\n", |
| 95 | 107 |
" 'bbc-vamp-plugins:bbc-intensity',\n", |
| ... | ... | |
| 190 | 202 |
] |
| 191 | 203 |
} |
| 192 | 204 |
], |
| 193 |
"prompt_number": 5 |
|
| 205 |
"prompt_number": 28 |
|
| 206 |
}, |
|
| 207 |
{
|
|
| 208 |
"cell_type": "markdown", |
|
| 209 |
"metadata": {},
|
|
| 210 |
"source": [ |
|
| 211 |
"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." |
|
| 212 |
] |
|
| 194 | 213 |
}, |
| 195 | 214 |
{
|
| 196 | 215 |
"cell_type": "code", |
| ... | ... | |
| 201 | 220 |
"language": "python", |
| 202 | 221 |
"metadata": {},
|
| 203 | 222 |
"outputs": [], |
| 204 |
"prompt_number": 6 |
|
| 223 |
"prompt_number": 29 |
|
| 224 |
}, |
|
| 225 |
{
|
|
| 226 |
"cell_type": "markdown", |
|
| 227 |
"metadata": {},
|
|
| 228 |
"source": [ |
|
| 229 |
"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." |
|
| 230 |
] |
|
| 205 | 231 |
}, |
| 206 | 232 |
{
|
| 207 | 233 |
"cell_type": "code", |
Also available in: Unified diff