Mercurial > hg > dml-open-backendtools
comparison pyspark/timeside_vamp.py @ 0:e34cf1b6fe09 tip
commit
author | Daniel Wolff |
---|---|
date | Sat, 20 Feb 2016 18:14:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e34cf1b6fe09 |
---|---|
1 # Part of DML (Digital Music Laboratory) | |
2 # | |
3 # This program is free software; you can redistribute it and/or | |
4 # modify it under the terms of the GNU General Public License | |
5 # as published by the Free Software Foundation; either version 2 | |
6 # of the License, or (at your option) any later version. | |
7 # | |
8 # This program is distributed in the hope that it will be useful, | |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 # GNU General Public License for more details. | |
12 # | |
13 # You should have received a copy of the GNU General Public | |
14 # License along with this library; if not, write to the Free Software | |
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
16 | |
17 #!/usr/bin/python | |
18 # -*- coding: utf-8 -*- | |
19 """ | |
20 Created on Fri Oct 11 13:22:37 2013 | |
21 | |
22 @author: thomas | |
23 """ | |
24 | |
25 from __future__ import division | |
26 | |
27 import matplotlib.pyplot as plt | |
28 import numpy as np | |
29 import sys | |
30 import os | |
31 | |
32 # NOTE: this is only for debugging purposes, we can | |
33 # now use a regular timeside and sonic annotator installation, | |
34 #sudo ln -s ../../sonic_annotator/sonic-annotator-0.7-linux-amd64/sonic-annotator /usr/sbin/ | |
35 #sys.path.append(os.getcwd() + '../../sonic_annotator/sonic-annotator-0.7-linux-amd64/') | |
36 | |
37 import timeside | |
38 from timeside.analyzer.core import AnalyzerResult, AnalyzerResultContainer | |
39 from timeside import __version__ | |
40 from vamp_plugin_dml import * | |
41 | |
42 def transform(wav_file = 'sweep.wav'): | |
43 | |
44 | |
45 # normal | |
46 d = timeside.decoder.file.FileDecoder(wav_file) | |
47 | |
48 # Get available Vamp plugins list | |
49 from timeside.analyzer.vamp_plugin import VampSimpleHost | |
50 plugins_list = VampSimpleHostDML.get_plugins_list() | |
51 | |
52 # Display avalaible plugins | |
53 print 'index \t soname \t \t identifier \t output ' | |
54 print '------ \t \t ---------- \t ------ ' | |
55 for index, line in zip(xrange(len(plugins_list)),plugins_list): | |
56 print '%d : %s \t %s \t %s' % (index,line[0],line[1],line[2]) | |
57 | |
58 # Let's choose #7 | |
59 my_plugin = plugins_list[0]#11 | |
60 print my_plugin | |
61 | |
62 # | |
63 # Vamp plugin Analyzer | |
64 #vamp = timeside.analyzer.vamp_plugin.VampSimpleHostDML([my_plugin]) | |
65 vamp = VampSimpleHostDML([my_plugin]) | |
66 #vamp = timeside.analyzer.VampSimpleHostDML() | |
67 | |
68 myPipe = (d | vamp ).run() | |
69 | |
70 # Get the vamp plugin result and plot it | |
71 for key in vamp.results.keys(): | |
72 print vamp.results[key].data | |
73 res_vamp = vamp.results[key] | |
74 | |
75 | |
76 # test storage as HDF5 | |
77 #vamp.results.to_hdf5(wav_file + '.h5') | |
78 #res_hdf5 = vamp.results.from_hdf5(wav_file + '.h5') | |
79 #print '%15s' % 'from hdf5:', | |
80 #print res_hdf5 | |
81 | |
82 return res_vamp | |
83 | |
84 # res_vamp = vamp.results['vamp_simple_host.percussiononsets.detectionfunction'] | |
85 | |
86 if __name__ == "__main__": | |
87 if len(sys.argv) >= 2: | |
88 transform(sys.argv[1]) | |
89 else: | |
90 transform() | |
91 |