From 1c674ec90cab49bfe2da886ddc34b488df470597 Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Wed, 16 Oct 2013 00:29:35 +0200 Subject: [PATCH] Add Processor a post_process() function. analyzer will produce the Results during that post-process --- tests/api/exempleCMMR_vamp.py | 7 ++++--- timeside/analyzer/aubio_melenergy.py | 2 +- timeside/analyzer/aubio_mfcc.py | 2 +- timeside/analyzer/aubio_pitch.py | 2 +- timeside/analyzer/aubio_specdesc.py | 2 +- timeside/analyzer/aubio_temporal.py | 2 +- timeside/analyzer/dc.py | 2 +- timeside/analyzer/irit_speech_4hz.py | 2 +- timeside/analyzer/irit_speech_entropy.py | 2 +- timeside/analyzer/level.py | 2 +- timeside/analyzer/spectrogram.py | 2 +- timeside/analyzer/vamp_plugin.py | 2 +- timeside/analyzer/waveform.py | 2 +- timeside/analyzer/yaafe.py | 2 +- timeside/api.py | 7 +++++++ timeside/core.py | 7 +++++++ 16 files changed, 31 insertions(+), 16 deletions(-) diff --git a/tests/api/exempleCMMR_vamp.py b/tests/api/exempleCMMR_vamp.py index a0343ae..36a03d6 100644 --- a/tests/api/exempleCMMR_vamp.py +++ b/tests/api/exempleCMMR_vamp.py @@ -11,8 +11,8 @@ import matplotlib.pyplot as plt import numpy as np import sys -wav_file = sys.argv[-1] -#wav_file = '/home/thomas/code/timeside/voix.wav' +#wav_file = sys.argv[-1] +wav_file = '/home/thomas/code/timeside/voix.wav' # normal d = timeside.decoder.FileDecoder(wav_file) @@ -50,7 +50,8 @@ max_freq = (N // 2 + 1) / N * spec_res.frame_metadata.samplerate # Get the vamp plugin result and plot it -vamp.results.keys() +for key in vamp.results.keys(): + print vamp.results[key].data res_vamp = vamp.results['vamp_simple_host.percussiononsets.detectionfunction'] diff --git a/timeside/analyzer/aubio_melenergy.py b/timeside/analyzer/aubio_melenergy.py index eb8b702..d1ac026 100644 --- a/timeside/analyzer/aubio_melenergy.py +++ b/timeside/analyzer/aubio_melenergy.py @@ -72,7 +72,7 @@ class AubioMelEnergy(Analyzer): self.block_read += 1 return frames, eod - def release(self): + def post_process(self): melenergy = self.new_result(data_mode='value', time_mode='framewise') diff --git a/timeside/analyzer/aubio_mfcc.py b/timeside/analyzer/aubio_mfcc.py index 5d7f14a..c29c20c 100644 --- a/timeside/analyzer/aubio_mfcc.py +++ b/timeside/analyzer/aubio_mfcc.py @@ -73,7 +73,7 @@ class AubioMfcc(Analyzer): self.block_read += 1 return frames, eod - def release(self): + def post_process(self): # MFCC mfcc = self.new_result(data_mode='value', time_mode='framewise') diff --git a/timeside/analyzer/aubio_pitch.py b/timeside/analyzer/aubio_pitch.py index f9e53ea..76bdb28 100644 --- a/timeside/analyzer/aubio_pitch.py +++ b/timeside/analyzer/aubio_pitch.py @@ -71,7 +71,7 @@ class AubioPitch(Analyzer): self.block_read += 1 return frames, eod - def release(self): + def post_process(self): # set Result pitch = self.new_result(data_mode='value', time_mode='framewise') diff --git a/timeside/analyzer/aubio_specdesc.py b/timeside/analyzer/aubio_specdesc.py index 4ebbb68..175cf08 100644 --- a/timeside/analyzer/aubio_specdesc.py +++ b/timeside/analyzer/aubio_specdesc.py @@ -79,7 +79,7 @@ class AubioSpecdesc(Analyzer): self.specdesc[method](fftgrain)[0]] return frames, eod - def release(self): + def post_process(self): # For each method store results in container for method in self.methods: diff --git a/timeside/analyzer/aubio_temporal.py b/timeside/analyzer/aubio_temporal.py index 49212f9..8c9d03a 100644 --- a/timeside/analyzer/aubio_temporal.py +++ b/timeside/analyzer/aubio_temporal.py @@ -78,7 +78,7 @@ class AubioTemporal(Analyzer): self.block_read += 1 return frames, eod - def release(self): + def post_process(self): #--------------------------------- # Onsets diff --git a/timeside/analyzer/dc.py b/timeside/analyzer/dc.py index 2b9f468..88b5911 100644 --- a/timeside/analyzer/dc.py +++ b/timeside/analyzer/dc.py @@ -57,7 +57,7 @@ class MeanDCShift(Analyzer): self.values = numpy.append(self.values, numpy.mean(frames)) return frames, eod - def release(self): + def post_process(self): dc_result = self.new_result(data_mode='value', time_mode='global') # Set Data diff --git a/timeside/analyzer/irit_speech_4hz.py b/timeside/analyzer/irit_speech_4hz.py index 8d05487..1e5e876 100644 --- a/timeside/analyzer/irit_speech_4hz.py +++ b/timeside/analyzer/irit_speech_4hz.py @@ -101,7 +101,7 @@ class IRITSpeech4Hz(Analyzer): return frames, eod - def release(self): + def post_process(self): ''' ''' diff --git a/timeside/analyzer/irit_speech_entropy.py b/timeside/analyzer/irit_speech_entropy.py index bc034b4..8f84544 100644 --- a/timeside/analyzer/irit_speech_entropy.py +++ b/timeside/analyzer/irit_speech_entropy.py @@ -62,7 +62,7 @@ class IRITSpeechEntropy(Analyzer): self.entropyValue.append(entropy(frames)) return frames, eod - def release(self): + def post_process(self): entropyValue = array(self.entropyValue) w = self.modulLen * self.samplerate() / self.blocksize() diff --git a/timeside/analyzer/level.py b/timeside/analyzer/level.py index ef2c185..29f0237 100644 --- a/timeside/analyzer/level.py +++ b/timeside/analyzer/level.py @@ -64,7 +64,7 @@ class Level(Analyzer): np.mean(np.square(frames))) return frames, eod - def release(self): + def post_process(self): # Max level max_level = self.new_result(data_mode='value', time_mode='global') diff --git a/timeside/analyzer/spectrogram.py b/timeside/analyzer/spectrogram.py index 48c7275..17b6d78 100644 --- a/timeside/analyzer/spectrogram.py +++ b/timeside/analyzer/spectrogram.py @@ -64,7 +64,7 @@ class Spectrogram(Analyzer): return frames, eod - def release(self): + def post_process(self): # set Result spectrogram = self.new_result(data_mode='value', time_mode='framewise') diff --git a/timeside/analyzer/vamp_plugin.py b/timeside/analyzer/vamp_plugin.py index 5e64505..5072ac5 100644 --- a/timeside/analyzer/vamp_plugin.py +++ b/timeside/analyzer/vamp_plugin.py @@ -63,7 +63,7 @@ class VampSimpleHost(Analyzer): pass return frames, eod - def release(self): + def post_process(self): #plugin = 'vamp-example-plugins:amplitudefollower:amplitude' wavfile = self.mediainfo()['uri'].split('file://')[-1] diff --git a/timeside/analyzer/waveform.py b/timeside/analyzer/waveform.py index a3da8f4..8d5b0c9 100644 --- a/timeside/analyzer/waveform.py +++ b/timeside/analyzer/waveform.py @@ -63,7 +63,7 @@ class Waveform(Analyzer): return frames, eod - def release(self): + def post_process(self): # set Result waveform = self.new_result(data_mode='value', time_mode='framewise') diff --git a/timeside/analyzer/yaafe.py b/timeside/analyzer/yaafe.py index f0bee2e..0ad8b3a 100644 --- a/timeside/analyzer/yaafe.py +++ b/timeside/analyzer/yaafe.py @@ -98,7 +98,7 @@ class Yaafe(Analyzer): return frames, eod - def release(self): + def post_process(self): # Get feature extraction results from yaafe featNames = self.yaafe_engine.getOutputs().keys() if len(featNames) == 0: diff --git a/timeside/api.py b/timeside/api.py index 07f7063..ad2b374 100644 --- a/timeside/api.py +++ b/timeside/api.py @@ -75,6 +75,13 @@ class IProcessor(Interface): Warning: it is required to call setup() before this method.""" + def post_process(self): + ''' + Post-Process data after processign the input frames with process() + + Processors such as analyzers will produce Results during the Post-Process + ''' + def release(self): """Release resources owned by this processor. The processor cannot be used anymore after calling this method.""" diff --git a/timeside/core.py b/timeside/core.py index 4804ad2..7bcc1bf 100644 --- a/timeside/core.py +++ b/timeside/core.py @@ -111,6 +111,10 @@ class Processor(Component): def process(self, frames, eod): return frames, eod + @interfacedoc + def post_process(self): + pass + @interfacedoc def release(self): pass @@ -259,6 +263,9 @@ class ProcessPipe(object): for item in items: frames, eod = item.process(frames, eod) + for item in items: + item.post_process() + for item in items: item.release() -- 2.39.5