comparison vamp/process.py @ 140:1a494598ee2b

Support step size, block size, process timestamp method kwargs
author Chris Cannam
date Wed, 08 Jul 2015 12:46:04 +0100
parents b8fe675f9c3f
children 79b050ca2fc2
comparison
equal deleted inserted replaced
139:aa96f69e2f14 140:1a494598ee2b
57 if ix in results: 57 if ix in results:
58 for r in results[ix]: 58 for r in results[ix]:
59 yield { o: r } 59 yield { o: r }
60 60
61 61
62 def process_audio(data, sample_rate, plugin_key, output = "", parameters = {}): 62 def process_audio(data, sample_rate, plugin_key, output = "", parameters = {}, **kwargs):
63 """Process audio data with a Vamp plugin, and make the results from a 63 """Process audio data with a Vamp plugin, and make the results from a
64 single plugin output available as a generator. 64 single plugin output available as a generator.
65 65
66 The provided data should be a 1- or 2-dimensional list or NumPy 66 The provided data should be a 1- or 2-dimensional list or NumPy
67 array of floats. If it is 2-dimensional, the first dimension is 67 array of floats. If it is 2-dimensional, the first dimension is
84 84
85 If you would prefer to obtain all features in a single output 85 If you would prefer to obtain all features in a single output
86 structure, consider using vamp.collect() instead. 86 structure, consider using vamp.collect() instead.
87 """ 87 """
88 88
89 plugin, step_size, block_size = vamp.load.load_and_configure(data, sample_rate, plugin_key, parameters) 89 plugin, step_size, block_size = vamp.load.load_and_configure(data, sample_rate, plugin_key, parameters, **kwargs)
90 90
91 if output == "": 91 if output == "":
92 output = plugin.get_output(0)["identifier"] 92 output = plugin.get_output(0)["identifier"]
93 93
94 ff = vamp.frames.frames_from_array(data, step_size, block_size) 94 ff = vamp.frames.frames_from_array(data, step_size, block_size)
167 yield r 167 yield r
168 168
169 plugin.unload() 169 plugin.unload()
170 170
171 171
172 def process_audio_multiple_outputs(data, sample_rate, plugin_key, outputs, parameters = {}): 172 def process_audio_multiple_outputs(data, sample_rate, plugin_key, outputs, parameters = {}, **kwargs):
173 """Process audio data with a Vamp plugin, and make the results from a 173 """Process audio data with a Vamp plugin, and make the results from a
174 set of plugin outputs available as a generator. 174 set of plugin outputs available as a generator.
175 175
176 The provided data should be a 1- or 2-dimensional list or NumPy 176 The provided data should be a 1- or 2-dimensional list or NumPy
177 array of floats. If it is 2-dimensional, the first dimension is 177 array of floats. If it is 2-dimensional, the first dimension is
191 represented as a dictionary containing, optionally, timestamp and 191 represented as a dictionary containing, optionally, timestamp and
192 duration (RealTime objects), label (string), and a 1-dimensional 192 duration (RealTime objects), label (string), and a 1-dimensional
193 array of float values. 193 array of float values.
194 """ 194 """
195 195
196 plugin, step_size, block_size = vamp.load.load_and_configure(data, sample_rate, plugin_key, parameters) 196 plugin, step_size, block_size = vamp.load.load_and_configure(data, sample_rate, plugin_key, parameters, **kwargs)
197 197
198 ff = vamp.frames.frames_from_array(data, step_size, block_size) 198 ff = vamp.frames.frames_from_array(data, step_size, block_size)
199 199
200 for r in process_with_initialised_plugin(ff, sample_rate, step_size, plugin, outputs): 200 for r in process_with_initialised_plugin(ff, sample_rate, step_size, plugin, outputs):
201 yield r 201 yield r